IP addressing error with docker with docker-compose - docker

I have mounted two identical docker on two ubuntu vps with docker-compose.
The concern is that the first one works well, and the pilces dialogue between it, the second one not.
What I see is that the ip set by default in 1 / is 172.X.X.X and the one set in 2 / is 192.X.X.X.
I am on virgin vps, no particular configuration file ... but I do not see how this is possible.
Here is the docker-compose
version: '2.4'
services:
redis:
image: redis:alpine
db:
image: mariadb:10.5
working_dir: /application
command: [mysqld, --character-set-server=utf8mb4, --collation-server=utf8mb4_unicode_ci, --innodb-file-format=Barracuda, --innodb-large-prefix=1, --innodb-file-per-table=1]
volumes:
- pimcore-demo-database:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=ROOT
- MYSQL_DATABASE=pimcore
- MYSQL_USER=pimcore
- MYSQL_PASSWORD=pimcore
php:
image: pimcore/pimcore:PHP8.0-apache
volumes:
- .:/var/www/html:cached
ports:
- 80:80
- 443:443
environment:
- APACHE_DOCUMENT_ROOT=/var/www/html/public
php-debug:
image: pimcore/pimcore:PHP8.0-apache-debug
volumes:
- .:/var/www/html:cached
ports:
- 88:80
environment:
- PHP_IDE_CONFIG="serverName=localhost"
- APACHE_DOCUMENT_ROOT=/var/www/html/public
volumes:
pimcore-demo-database:
thank you in advance

Try to add networking config inside your compose yml to use specific IPs, like following:
more infos on https://docs.docker.com/compose/networking/#use-a-pre-existing-network
version: '2.4'
services:
redis:
image: redis:alpine
db:
image: mariadb:10.5
working_dir: /application
command: [mysqld, --character-set-server=utf8mb4, --collation-server=utf8mb4_unicode_ci, --innodb-file-format=Barracuda, --innodb-large-prefix=1, --innodb-file-per-table=1]
volumes:
- pimcore-demo-database:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=ROOT
- MYSQL_DATABASE=pimcore
- MYSQL_USER=pimcore
- MYSQL_PASSWORD=pimcore
networks: # <-- Add this line
- you_own_network # <-- Add this line
php:
image: pimcore/pimcore:PHP8.0-apache
volumes:
- .:/var/www/html:cached
ports:
- 80:80
- 443:443
environment:
- APACHE_DOCUMENT_ROOT=/var/www/html/public
networks: # <-- Add this line
- you_own_network # <-- Add this line
php-debug:
image: pimcore/pimcore:PHP8.0-apache-debug
volumes:
- .:/var/www/html:cached
ports:
- 88:80
environment:
- PHP_IDE_CONFIG="serverName=localhost"
- APACHE_DOCUMENT_ROOT=/var/www/html/public
networks: # <-- Add this line
- you_own_network # <-- Add this line
volumes:
pimcore-demo-database:
networks: # <-- Add this block
you_own_network:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.123.123.0/24

Ok solution :
sudo snap remove docker
sudo rm -R /var/lib/docker
sudo apt-get remove docker docker-engine docker.io
sudo apt-get update
https://doc.ubuntu-fr.org/docker
systemctl start docker

Related

Pimcore Unsupported config option for services

In official pimcore document below docker-compose.yaml file is available but when i execute
following command. I am getting error.
ERROR: The Compose file './docker-compose.yaml' is invalid because:
Unsupported config option for services: 'nginx'
Unsupported config option for volumes: 'pimcore-database'
I checked all indentation. they are correct can anyone help below
Here is the official installation guide:
https://github.com/pimcore/demo
services:
redis:
image: redis:alpine
command: [ redis-server, --maxmemory 128mb, --maxmemory-policy volatile-lru, --save "" ]
db:
image: mariadb:10.7
working_dir: /application
command: [mysqld, --character-set-server=utf8mb4, --collation-server=utf8mb4_unicode_ci, --innodb-file-per-table=1]
volumes:
- pimcore-database:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=ROOT
- MYSQL_DATABASE=pimcore
- MYSQL_USER=pimcore
- MYSQL_PASSWORD=pimcore
nginx:
image: nginx:stable-alpine
ports:
- "8080:80"
volumes:
- .:/var/www/html:ro
- ./.docker/nginx.conf:/etc/nginx/conf.d/default.conf:ro
depends_on:
- php-fpm
- php-fpm-debug
php-fpm:
user: '1000:1000' # set to your uid:gid
image: pimcore/pimcore:PHP8.1-fpm
environment:
COMPOSER_HOME: /var/www/html
depends_on:
- db
volumes:
- .:/var/www/html
- pimcore-tmp-storage:/tmp
php-fpm-debug:
user: '1000:1000' # set to your uid:gid
image: pimcore/pimcore:PHP8.1-fpm-debug
depends_on:
- db
volumes:
- .:/var/www/html
- pimcore-tmp-storage:/tmp
environment:
PHP_IDE_CONFIG: serverName=localhost
COMPOSER_HOME: /var/www/html
supervisord:
user: '1000:1000' # set to your uid:gid
image: pimcore/pimcore:PHP8.1-supervisord
depends_on:
- db
volumes:
- .:/var/www/html
- ./.docker/supervisord.conf:/etc/supervisor/conf.d/pimcore.conf:ro
volumes:
pimcore-database:
pimcore-tmp-storage:
David Maze comment was on point. You must also consider to specify a supported version, because 3.8 is the last version right now, but maybe won't work in your case. For example, in my case (the docker-compose.yaml for the Pimcore demo project) the version is 3.3.
The solution that I found it was adding the version tag in the YML file:
version: '3'
services:
redis:
image: redis:alpine
command: [ redis-server, --maxmemory 128mb, --maxmemory-policy volatile-lru, --save "" ]
...

Why is my app not installed? File not found

This is my docker-compose.yml. I am trying to deploy app and mysql,I added network.
version: '3'
services:
#PHP Service
app:
image: lscr.io/linuxserver/bookstack
container_name: bookstack
restart: unless-stopped
environment:
- DB_HOST=mysql
- DB_USER=quantox
- DB_PASS=****
- DB_DATABASE=bookstackapp
working_dir: /var/www
volumes:
- ./:/var/www
- ./php/local.ini:/usr/local/etc/php/conf.d/local.ini
ports:
- 6875:80
networks:
- app-network
db:
image: mysql:5.7.22
container_name: mysql
restart: unless-stopped
ports:
- 33060:3306
environment:
- MYSQL_ROOT_PASSWORD=***
- TZ=Europe/Budapest
- MYSQL_DATABASE=bookstackapp
- MYSQL_USER=bookstack
- MYSQL_PASSWORD=****
volumes:
- dbdata:/var/lib/mysql/
- ./mysql/my.cnf:/etc/mysql/my.cnf
networks:
- app-network
#Docker Networks
networks:
app-network:
driver: bridge
#Volumes
volumes:
dbdata:
driver: local
After I go for up -d
I got
Name Command State Ports
-----------------------------------------------------------------------------------------------
bookstack /init Up 443/tcp, 0.0.0.0:6875->80/tcp,:::6875->80/tcp
mysql docker-entrypoint.sh mysqld Up 0.0.0.0:33060->3306/tcp,:::33060->3306/tcp
But in browser localhost:6875 shows
File not found.
Why? Both my app and mysql are on same network. What should I check now?
When using volumes (-v flags) permissions issues can arise between the host OS and the container, you could avoid this issue by allowing you to specify the user PUID and group PGID.

ERROR: In file './docker-compose.yml', service name True must be a quoted string, i.e. 'True'

My docker-compose.yml looks like the below. When i run docker-compose up I get the below error.
ERROR: In file './docker-compose.yml', the service name True must be a quoted string, i.e. 'True'.
version: '3'
services:
db:
restart: always
image: postgres:9.6-alpine
container_name: pleroma_postgres
networks:
- pleroma
volumes:
- ./postgres:/var/lib/postgresql/data
web:
build: .
image: pleroma
container_name: pleroma_web
restart: always
environment:
- VIRTUAL_HOST=<myplaceholderhost>
- VIRTUAL_PORT=4000
- LETSENCRYPT_HOST=<myplaceholderhost>
- LETENCRYPT_EMAIL=<myplaceholderemail>
expose:
- "4000"
volumes:
- ./uploads:/pleroma/uploads
depends_on:
- db
nginx:
image: jwilder/nginx-proxy
container_name: nginx
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- /apps/docker-articles/nginx/vhost.d:/etc/nginx/vhost.d
- /apps/docker-articles/nginx/certs:/etc/nginx/certs:ro
- /apps/docker-articles/nginx/html:/usr/share/nginx/html
restart: always
ports:
- "80:80"
- "443:443"
labels:
com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy: "true"
networks:
- pleroma
letsencrypt:
image: jrcs/letsencrypt-nginx-proxy-companion:v1.5
container_name: letsencrypt
volumes_from:
- nginx
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /apps/docker-articles/nginx/vhost.d:/etc/nginx/vhost.d
- /apps/docker/articles/nginx/certs:/etc/nginx/certs:rw
- /apps/docker-articles/nginx/html:/usr/share/nginx/html
networks:
pleroma:
My docker version is
Docker version 18.06.1-ce, build e68fc7a
My docker compose version is
docker-compose version 1.23.1, build b02f1306
Running CoreOS version 1911.3.0
I ended up resolving this issue by modifying the nginx and letsencrypt portions of my docker-compose.yml file to be as follows.
nginx:
image: jwilder/nginx-proxy
container_name: nginx
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- /apps/docker-articles/nginx/vhost.d:/etc/nginx/vhost.d
- /apps/docker-articles/nginx/certs:/etc/nginx/certs:ro
- /apps/docker-articles/nginx/html:/usr/share/nginx/html
restart: always
ports:
- "80:80"
- "443:443"
labels:
- "NGINX_PROXY_CONTAINER=true"
networks:
- pleroma
letsencrypt:
image: jrcs/letsencrypt-nginx-proxy-companion:v1.5
container_name: letsencrypt
environment:
- NGINX_PROXY_CONTAINER=true
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /apps/docker-articles/nginx/vhost.d:/etc/nginx/vhost.d
- /apps/docker/articles/nginx/certs:/etc/nginx/certs:rw
- /apps/docker-articles/nginx/html:/usr/share/nginx/html
It seems "volumes_from" is deprecated in docker-compose v3. As well as I had forgotted quotes around my label and needed to set my environment within letsencrypt.
in CentOS env your .yml file directory must be /usr/local/bin

Docker Compose file to Docker Stack

I have found an awesome repo that uses docker-compose however I would like to use it Docker Cloud Stacks (I am a newbie).
What would I have to do to be able to swap it over?
docker-compose:
version: "2"
services:
mariadb:
image: wodby/mariadb:10.2-3.0.2
php:
# 1. Images with vanilla WordPress – wodby/wordpress:[WP_VERSION]-[PHP_VERSION]-[STABILITY_TAG].
image: wodby/wordpress:4-7.2-3.3.1
environment:
PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025
PHP_FPM_CLEAR_ENV: "no"
volumes:
- codebase:/var/www/html
nginx:
image: wodby/wordpress-nginx:4-1.13-3.0.2
environment:
NGINX_STATIC_CONTENT_OPEN_FILE_CACHE: "off"
NGINX_ERROR_LOG_LEVEL: debug
NGINX_BACKEND_HOST: php
volumes:
- codebase:/var/www/html
depends_on:
- php
labels:
- 'traefik.backend=nginx'
- 'traefik.port=80'
- 'traefik.frontend.rule=Host:wp.docker.localhost'
varnish:
image: wodby/wordpress-varnish:4.1-2.3.1
depends_on:
- nginx
environment:
VARNISH_SECRET: secret
VARNISH_BACKEND_HOST: nginx
VARNISH_BACKEND_PORT: 80
labels:
- 'traefik.backend=varnish'
- 'traefik.port=6081'
- 'traefik.frontend.rule=Host:varnish.wp.docker.localhost'
redis:
image: wodby/redis:4.0-2.1.4
blackfire:
image: blackfire/blackfire
environment:
BLACKFIRE_SERVER_ID:
BLACKFIRE_SERVER_TOKEN:
mailhog:
image: mailhog/mailhog
labels:
- 'traefik.backend=mailhog'
- 'traefik.port=8025'
- 'traefik.frontend.rule=Host:mailhog.wp.docker.localhost'
portainer:
image: portainer/portainer
command: --no-auth -H unix:///var/run/docker.sock
volumes:
- /var/run/docker.sock:/var/run/docker.sock
labels:
- 'traefik.backend=portainer'
- 'traefik.port=9000'
- 'traefik.frontend.rule=Host:portainer.wp.docker.localhost'
traefik:
image: traefik
command: -c /dev/null --web --docker --logLevel=INFO
ports:
- '8000:80'
# - '8080:8080' # Dashboard
volumes:
- /var/run/docker.sock:/var/run/docker.sock
volumes:
codebase:

How to setup sockets on docker-compose version 2?

Using:
ubuntu:14.04
docker 1.10.3
docker-compose 1.6.2
I can set up sockets on docker-compose version 1 by doing something like this:
container_name_1:
container_name: container_1
image: <- image ->
volumes:
- "/root:/home/app"
- "/var/run/docker.sock:/var/run/docker.sock"
- "/usr/bin/docker:/usr/bin/docker:ro"
- "/usr/lib/x86_64-linux-gnu/libapparmor.so.1:/usr/lib/x86_64-linux-gnu/libapparmor.so.1:ro"
- "/usr/lib/x86_64-linux-gnu/libapparmor.so.1.1.0:/usr/lib/x86_64-linux-gnu/libapparmor.so.1.1.0:ro"
container_name_2:
container_name: container_2
image: <- image ->
volumes:
- "/root:/home/app"
- "/var/run/docker.sock:/var/run/docker.sock"
- "/usr/bin/docker:/usr/bin/docker:ro"
- "/usr/lib/x86_64-linux-gnu/libapparmor.so.1:/usr/lib/x86_64-linux-gnu/libapparmor.so.1:ro"
- "/usr/lib/x86_64-linux-gnu/libapparmor.so.1.1.0:/usr/lib/x86_64-linux-gnu/libapparmor.so.1.1.0:ro"
However when I try in the version 2 syntax it doesn't work:
version: '2'
services:
mysql:
image: mysql
ports:
- "3000:3306"
container_name: mysql_container
environment:
- MYSQL_ROOT_PASSWORD=<-- password -->
- MYSQL_DATABASE=<-- database -->
volumes_from:
- data
data:
image: ubuntu
container_name: data_container_name
volumes:
- /var/lib/mysql
do_something:
image: <-- image -->
container_name: action_container
volumes_from:
- data:/var/lib/mysql
- /var/run/docker.sock:/var/run/docker.sock
- /usr/bin/docker:/usr/bin/docker:ro
- /usr/lib/x86_64-linux-gnu/libapparmor.so.1:/usr/lib/x86_64-linux-gnu/libapparmor.so.1:ro
- /usr/lib/x86_64-linux-gnu/libapparmor.so.1.1.0:/usr/lib/x86_64-linux-gnu/libapparmor.so.1.1.0:ro
depends_on:
- data
- mysql
volumes:
data_container_name:
driver: local
The error I get is:
ERROR: Unknown volumes_from type '/usr/bin/docker' in '/usr/bin/docker:/usr/bin/docker:ro'
I have a docker executable at that location and it works when using the version 1 format.
Any ideas?
The volumes_from syntax in version 2 mentions:
volumes_from:
- service_name
- service_name:ro
- container:container_name
- container:container_name:rw
/usr/bin/docker is neither a container or a service name.
volumes_from:
- data:/var/lib/mysql <=== works
- /usr/bin/docker:/usr/bin/docker:ro <=== won't work
You would need to use volumes: in order to mount paths:
- /var/run/docker.sock:/var/run/docker.sock

Resources