I am not able to create these containers in Oracle Cloud - mysql

I receive the following error:
WARNING: The requested image is platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
standard_init_linux.go:228: exec user process caused: exec format error
#!/bin/bash
version: "3.7"
services:
db:
platform: linux/amd64
image: mysql
command: --default-authentication-plugin=mysql_native_password
environment:
MYSQL_ROOT_PASSWORD: "Root193782"
MYSQL_DATABASE: "test"
ports:
- "3306:3306"
volumes:
- /data/mysql:/var/lib/mysql
restart: always
networks:
- mysql-network
phpmyadmin:
platform: linux/amd64
image: phpmyadmin/phpmyadmin
environment:
MYSQL_ROOT_PASSWORD: "Root193782"
ports:
- "8080:80"
volumes:
- /data/php/admin/uploads.ini:/usr/local/etc/php/conf.d/php-phpmyadmin.ini
networks:
- mysql-network
networks:
mysql-network:

Related

Docker / phpmyadmin: Unable to connecto

I have the following docker-compose file.
version: "3.7"
services:
main:
container_name: buspack_main
build:
context: .
target: development
volumes:
- .:/usr/src/app
- /usr/src/app/node_modules
ports:
- ${API_PORT}:${API_PORT}
command: bash -c "npm install --save && npm run start:dev"
env_file:
- .env
networks:
- webnet
depends_on:
- db
links:
- db
restart: always
db:
container_name: buspack_db
image: mysql:5.7.33
networks:
- webnet
environment:
MYSQL_ROOT_PASSWORD: 123456
MYSQL_DATABASE: "backendnest"
ports:
- 23306:3306
restart: always
volumes:
- ./db:/var/lib/mysql:rw
phpmyadmin:
container_name: buspack_phpmyadmin
image: phpmyadmin/phpmyadmin
depends_on:
- db
restart: always
ports:
- '8030:80'
environment:
PMA_HOST: buspack_db
MYSQL_ROOT_PASSWORD: 123456
networks:
webnet:
volumes:
db: {}
My problem Is that when I try to login with phpmyadmin I get the following error:
mysqli::real_connect(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution
And also
mysqli::real_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution
Is there something I'm missing?
networks:
- webnet
add webnet network to phpmyadmin service
There are more options to solve the connection.
Add phpmyadmin container to webnet network as Def Soudani suggests. The YML example provided overrides the default network. Since the phpMyAdmin is lacking the network config, it won't be on the webnet docker network by default.
Remove all networks related config from the YML. Since compose already creates a default network (docs) for the containers within one YML file.
Use the PMA_ARBITRARY=1 (docs )which allows you to enter a database server hostname on login form.
Example of my YML setup with custom bridge networking:
version: '3.8'
services:
mysql:
image: mysql:5.7
container_name: myapp-mysql-db
restart: unless-stopped
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: ${DB_DATABASE}
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
MYSQL_PASSWORD: ${DB_PASSWORD}
MYSQL_USER: ${DB_USERNAME}
volumes:
- ./database/dbdata:/var/lib/mysql
networks:
- myapp-network
phpmyadmin:
image: phpmyadmin:latest
container_name: phpmyadmin
ports:
# 8080 is the host port and 80 is the docker port
- 8080:80
environment:
PMA_HOST: mysql
UPLOAD_LIMIT: 20M
MYSQL_USERNAME: ${DB_USERNAME}
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
restart: unless-stopped
networks:
# define your network where all containers are connected to each other
- myapp-network
networks:
myapp-network:
driver: bridge

Cannot resolve hostname in docker desktop windows

I have setup docker-compose to run phpmyadmin and mysql. Here is my docker-compose.yml
version: "3.9"
networks:
local_web_network:
driver: bridge
volumes:
mysql_data:
driver: local
services:
mysql:
image: mysql:8.0
container_name: local_mysql
restart: always
tty: true
ports:
- "3306:3306"
command: --default-authentication-plugin=mysql_native_password
environment:
MYSQL_DATABASE: local_master
MYSQL_ROOT_PASSWORD: secret
MYSQL_USER: homestead
MYSQL_PASSWORD: secret
volumes:
- mysql_data:/var/lib/mysql
networks:
- local_web_network
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: local_phpmyadmin
restart: always
tty: true
ports:
- "8083:80"
environment:
PMA_HOST: local_mysql
PMA_ABSOLUTE_URI: http://db.test
MYSQL_ROOT_PASSWORD: secret
networks:
- local_web_network
extra_hosts:
- 'db.test:127.0.0.1'
I have configured the windows hosts file with the below settings
127.0.0.1 db.test
I have successfully run the docker containers without any errors. I have tried accessing the http://127.0.0.1:8083 or http://db.test:8083 it works and displays the phpmyadmin login page.
But the problem here is, i am unable to access the page without specifying the port i.e http://db.test. How do i get this working without specifying the port?

How can I add phpMyAdmin in docker-compose

Hello everyone I have this docker-compose file
version: '3'
networks:
laravel:
services:
site:
build:
context: .
dockerfile: nginx.dockerfile
container_name: nginx
ports:
- "8080:80"
volumes:
- ./src:/var/www/html:delegated
depends_on:
- php
- mysql
networks:
- laravel
mysql:
image: mysql:5.7.29
container_name: mysql
restart: unless-stopped
tty: true
ports:
- "3306:3306"
volumes:
- ./mysql:/var/lib/mysql
environment:
MYSQL_DATABASE: gestionParking
MYSQL_USER: root
MYSQL_PASSWORD: root
MYSQL_ROOT_PASSWORD: root
SERVICE_TAGS: dev
SERVICE_NAME: mysql
networks:
- laravel
php:
build:
context: .
dockerfile: php.dockerfile
container_name: php
volumes:
- ./src:/var/www/html:delegated
ports:
- "9000:9000"
networks:
- laravel
composer:
build:
context: .
dockerfile: composer.dockerfile
container_name: composer
volumes:
- ./src:/var/www/html
working_dir: /var/www/html
depends_on:
- php
user: laravel
networks:
- laravel
entrypoint: ['composer', '--ignore-platform-reqs']
npm:
image: node:13.7
container_name: npm
volumes:
- ./src:/var/www/html
working_dir: /var/www/html
entrypoint: ['npm']
artisan:
build:
context: .
dockerfile: php.dockerfile
container_name: artisan
volumes:
- ./src:/var/www/html:delegated
depends_on:
- mysql
working_dir: /var/www/html
user: laravel
entrypoint: ['php', '/var/www/html/artisan']
networks:
- laravel
And I want to add phpMyAdmin to have graphical interface of my database, I try this but it doesn't work.
...
mysql:
image: mysql:5.7.29
container_name: mysql
restart: unless-stopped
tty: true
ports:
- "3306:3306"
volumes:
- ./mysql:/var/lib/mysql
environment:
MYSQL_DATABASE: gestionParking
MYSQL_USER: root
MYSQL_PASSWORD: root
MYSQL_ROOT_PASSWORD: root
SERVICE_TAGS: dev
SERVICE_NAME: mysql
networks:
- laravel
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin
environment:
MYSQL_ROOT_PASSWORD: secret
PMA_HOST: mysql
PMA_PORT: 3306
restart: always
ports:
- "8081:80"
networks:
- laravel
I think it's possible, but I think I'm going about it wrong.
I know we need to make a connection between mysql service and phpmyadmin but I don't know how to do it.
Can I help me please
version: '3'
services:
nginx:
container_name: nginx
image: nginx:1.17
restart: always
ports:
- "9998:80"
volumes:
- ../:/var/www
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
links:
- php
php:
container_name: php
build:
context: .
dockerfile: Dockerfile
restart: always
volumes:
- ../:/var/www
- ~:/home
- ./php-config/php.ini:/usr/local/etc/php/php.ini
app:
build:
context: .
dockerfile: Dockerfile
image: hakase-labs/laravel
container_name: app
restart: unless-stopped
tty: true
environment:
SERVICE_NAME: app
SERVICE_TAGS: dev
working_dir: /var/www/html
volumes:
- ./:/var/www/html
networks:
- mynet
composer:
container_name: composer
image: composer:1.9.0
command: tail -f /dev/null
volumes:
- ../:/var/www
mysql:
container_name: mysql
image: mysql:5.7
command: mysqld --max-allowed-packet=64M --character-set-server=utf8 --collation-server=utf8_unicode_ci --init-connect='SET NAMES UTF8;' --innodb-flush-log-at-trx-commit=0
volumes:
# Mount mysl data directory to keep it perisstent on host system.
# Use this only in development environment
# Mysql cannot write to data folder as it is owned by user on host.
# So chown 999:999 data folder when it is first created
# Todo: For some reason we are not able to mount log directory from host to mysql container. We need to fix this in future so that we can better manage mysql logs from host machine - Harsha
#- ~/storage/mysql/log:/var/log/mysql
- ~/storage/mysql/data:/var/lib/mysql
environment:
- "MYSQL_ROOT_PASSWORD=pasword"
- "MYSQL_DATABASE=name"
- "MYSQL_USER=name"
- "MYSQL_PASSWORD=password"
ports:
- "3306:3306"
phpmyadmin:
container_name: phpmyadmin
image: phpmyadmin/phpmyadmin
restart: always
environment:
- PMA_HOST=mysql
- PMA_PORT=3306
ports:
- 8001:80
volumes:
- /sessions

Docker - Use same network and database for another app?

I've set up a development environment for an app on docker in which I'm using a specific network to connect the app to the database
version: '3'
services:
app:
image: appimg
container_name: appwww
build:
context: .
dockerfile: docker/Dockerfile
volumes:
- .:/var/www/html
ports:
- 9000:80
depends_on:
- mysql
network:
- appnet
mysql:
image: mysql:5.7
container_name: appdb
environment:
MYSQL_DATABASE: homestead
MYSQL_ROOT_PASSWORD: root
MYSQL_USERNAME: homestead
MYSQL_PASSWORD: password
volumes:
- dbdata:/var/lib/mysql
ports:
- 3306:3306
network:
- appnet
volumes:
dbdata:
driver: 'local'
network:
- appnet
My question is can I use the same network to connect to the same database from another app? something like this perhaps?
version: '3'
services:
anotherapp:
image: anotherappimg
container_name: anotherappwww
build:
context: .
dockerfile: docker/Dockerfile
volumes:
- .:/var/www/html
ports:
- 9000:80
depends_on:
- mysql
network:
- appnet
mysql:
image: mysql:5.7
container_name: anotherappdb
environment:
MYSQL_DATABASE: homestead
MYSQL_ROOT_PASSWORD: root
MYSQL_USERNAME: homestead
MYSQL_PASSWORD: password
volumes:
- dbdata:/var/lib/mysql
ports:
- 3306:3306
network:
- appnet
volumes:
dbdata:
driver: 'local'
network:
- appnet
Yes it's possible, you can have the setup done like this:
docker-compose.base.yml:
version: '3'
services:
mysql:
image: mysql:5.7
container_name: anotherappdb
environment:
MYSQL_DATABASE: homestead
MYSQL_ROOT_PASSWORD: root
MYSQL_USERNAME: homestead
MYSQL_PASSWORD: password
volumes:
- dbdata:/var/lib/mysql
ports:
- 3306:3306
network:
- appnet
volumes:
dbdata:
driver: 'local'
network:
- appnet
docker-compose.app.yml:
version: '3'
services:
app:
image: appimg
container_name: appwww
build:
context: .
dockerfile: docker/Dockerfile
volumes:
- .:/var/www/html
ports:
- 9000:80
depends_on:
- mysql
network:
- appnet
docker-compose.anotherapp.yml:
version: '3'
services:
anotherapp:
image: anotherappimg
container_name: anotherappwww
build:
context: .
dockerfile: docker/Dockerfile
volumes:
- .:/var/www/html
ports:
- 9000:1080
depends_on:
- mysql
network:
- appnet
Then you can start everything using:
docker-compose -f docker-compose.base.yml -f docker-compose.app.yml -f docker-compose.anotherapp.yml up -d
If you want to start only anotherapp, you'll remove -f docker-compose.app.yml from the previous command.
NOTE: I've changed the port mapping for anotherapp since they'd conflict with app if started at the same time.

Docker-Compose phpmyadmin and mysql together for local development

version: "3.1"
services:
redis:
image: redis:alpine
container_name: larablog-redis
the code was working fine until I added the following services
db:
image: mysql:8.0
container_name: larablog-mysql
working_dir: /application
volumes:
- ./src:/application
environment:
- MYSQL_ROOT_PASSWORD=rootpass
- MYSQL_DATABASE=larablog
- MYSQL_USER=larauser
- MYSQL_PASSWORD=larauserpass
ports:
- "8890:3306"
phpmyadmin:
image: phpmyadmin/phpmyadmin
environment:
PMA_ARBITRARY: 1
MYSQL_USER: larauser
MYSQL_PASSWORD: larauserpass
MYSQL_ROOT_PASSWORD: rootpass
ports:
- "80:80"
links:
# for mysql container
- "db:db"
volumes:
db:
driver: "local"
I am trying to follow a method I found on https://gotechnies.com/docker-compose-yml-mysql-phpmyadmin/ however I cannot start from scratch because I need the laravel framework as well
webserver:
image: nginx:alpine
container_name: larablog-webserver
working_dir: /application
volumes:
- ./src:/application
- ./phpdocker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
ports:
- "8888:80"
php-fpm:
build: phpdocker/php-fpm
container_name: larablog-php-fpm
working_dir: /application
volumes:
- ./src:/application
- ./phpdocker/php-fpm/php-ini-overrides.ini:/etc/php/7.1/fpm/conf.d/99-overrides.ini
I get this error when i try to run docker-compose up -d ...
ERROR: yaml.parser.ParserError: while parsing a block mapping
in ".\..\docker-compose.yml", line 27, column 6
expected <block end>, but found '<block mapping start>'
in ".\..\docker-compose.yml", line 35, column 9
How can I overcome this error?