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
Related
I am trying to get a couple of containers up and running, however I am running into some issues. I run this command:
docker-compose up -d --build itvdflab
and get this error
The Compose file './docker-compose.yaml' is invalid because:
Unsupported config option for services: 'itvdelab'
Unsupported config option for networks: 'itvdelabnw'
Here is the yaml file.
services:
itvdelab:
image: itversity/itvdelab
hostname: itvdelab
ports:
- "8888:8888"
volumes:
- "./itversity-material:/home/itversity/itversity-material"
- "./data:/data"
environment:
SHELL: /bin/bash
networks:
- itvdelabnw
depends_on:
- "cluster_util_db"
cluster_util_db:
image: postgres:13
ports:
- "6432:5432"
volumes:
- ./cluster_util_db_scripts:/docker-entrypoint-initdb.d
networks:
- itvdelabnw
environment:
POSTGRES_PASSWORD: itversity
itvdflab:
build:
context: .
dockerfile: images/pythonsql/Dockerfile
hostname: itvdflab
ports:
- "8888:8888"
volumes:
- "./itversity-material:/home/itversity/itversity-material"
- "./data:/data"
environment:
SHELL: /bin/bash
networks:
- itvdelabnw
depends_on:
- "pg.itversity.com"
pg.itversity.com:
image: postgres:13
ports:
- "5432:5432"
networks:
- itvdelabnw
environment:
POSTGRES_PASSWORD: itversity
networks:
itvdelabnw:
name: itvdelabnw
What changes do I need to make to get this working?
Your docker-compose.yml file is missing a version: line. Until very recently, this caused Docker Compose to interpret this as the original "version 1" Compose format, which doesn't have a top-level services: key and doesn't support Docker networks. The much newer Compose Specification claims that a version: key is optional, but in practice if you can't be guaranteed to use a very new version of Compose (built as a plugin to the docker binary) it's required. The most recent Compose file versions supported by the standalone Python docker-compose tool are 3.8 and 2.4 (you need the 2.x version for some resource-related constraints in non-Swarm installations).
# Add at the very beginning
version: '3.8'
Here is the revised copy:
version: '3.4'
services:
itvdelab:
image: itversity/itvdelab
hostname: itvdelab
ports:
- "8888:8888"
volumes:
- "./itversity-material:/home/itversity/itversity-material"
- "./data:/data"
environment:
SHELL: /bin/bash
networks:
- itvdelabnw
depends_on:
- "cluster_util_db"
cluster_util_db:
image: postgres:13
ports:
- "6432:5432"
volumes:
- ./cluster_util_db_scripts:/docker-entrypoint-initdb.d
networks:
- itvdelabnw
environment:
POSTGRES_PASSWORD: itversity
itvdflab:
build:
context: .
dockerfile: images/pythonsql/Dockerfile
hostname: itvdflab
ports:
- "8888:8888"
volumes:
- "./itversity-material:/home/itversity/itversity-material"
- "./data:/data"
environment:
SHELL: /bin/bash
networks:
- itvdelabnw
depends_on:
- "pg.itversity.com"
pg.itversity.com:
image: postgres:13
ports:
- "5432:5432"
networks:
- itvdelabnw
environment:
POSTGRES_PASSWORD: itversity
networks:
itvdelabnw:
name: itvdelabnw
and now I get the following error
ERROR: The Compose file './docker-compose.yaml' is invalid because:
services.pg.itversity.com.networks.itvdelabnw contains unsupported option: 'name'
for me work try different version. In my case work
version: '2.2'
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
I have a docker-compose file:
version: "2.3"
services:
backend:
image: registry.obs.liberty.edu/occ/panoptes:latest
restart: always
environment:
- SECRET_KEY=
- SQL_ENGINE=django_prometheus.db.backends.postgresql
- SQL_DATABASE=
- SQL_USER=
- SQL_PASSWORD=
- SQL_HOST=postgres_db_1
- SQL_PORT=5432
- SN_USER=
- SN_PASS=
- LDAP_USER=
- LDAP_PASS=
- ORA_USER=
- ORA_PASS=
volumes:
- static-data:/app/static:rw
networks:
- server_net
- db_net
mem_limit: 2g
server:
image: nginx:latest
restart: always
labels:
- traefik.enable=true
# insecure router (https redirect)
- traefik.http.routers.panoptes.middlewares=httpsRedirect
- traefik.http.routers.panoptes.rule=Host(`panoptes.obs.liberty.edu`) || Host(`ws://panoptes.obs.liberty.edu`)
# https router
- traefik.http.routers.panoptes-secure.rule=Host(`panoptes.obs.liberty.edu`) || Host(`wss://panoptes.obs.liberty.edu`)
docker ls shows me
local panoptes_static-data
But I get this error:
docker-compose up --build
ERROR: Named volume "static-data:/app/static:rw" is used in service "backend" but no declaration was found in the volumes section.
Just add below at the end of the file and it should work
volumes:
static-data:
Read the below for the docker-compose format
https://docs.docker.com/compose/compose-file/compose-file-v3/#volume-configuration-reference
I need to share a folder from my OSX machine with a running Docker container, but I can't find how to do it.
Here's a working Docker-compose file:
version: '2'
services:
mariadb:
image: 'bitnami/mariadb:10.3'
environment:
- MARIADB_ROOT_PASSWORD=bitnami
- MARIADB_USER=bn_moodle
- MARIADB_DATABASE=bitnami_moodle
- ALLOW_EMPTY_PASSWORD=yes
volumes:
- 'mariadb_data:/bitnami'
phpmyadmin:
image: 'bitnami/phpmyadmin:4'
ports:
- '8081:80'
- '4430:443'
depends_on:
- mariadb
volumes:
- 'phpmyadmin_data:/bitnami'
moodle:
image: 'bitnami/moodle:3'
environment:
- MARIADB_HOST=mariadb
- MARIADB_PORT_NUMBER=3306
- MOODLE_DATABASE_USER=bn_moodle
- MOODLE_DATABASE_NAME=bitnami_moodle
- ALLOW_EMPTY_PASSWORD=yes
ports:
- '80:80'
- '443:443'
volumes:
- 'moodle_data:/bitnami'
depends_on:
- mariadb
volumes:
mariadb_data:
driver: local
phpmyadmin_data:
driver: local
moodle_data:
driver: local
This file correctly starts 3 Docker containers, 1 for Moodle, 1 for MariaDb and 1 for Phpmyadmin.
What I need to do now is to share the content of a local folder with a folder inside the Moodle container. But I can't figure out how to change the Volumes key to reflect that. I tried with a mapping like:
moodle_data:
- moodle_data:/Users/macbook/Code/Php/moodle-docker/moodle/Users/macbook/Code/Php/moodle-docker/moodle
But it didn't work.. what am I doing wrong here? Thanks in advance to anybody who can help!
You need to map your host_folder with your container_folder using host_folder:container_folder. As mentioned on the comments:
moodle:
image: 'bitnami/moodle:3'
environment:
- MARIADB_HOST=mariadb
- MARIADB_PORT_NUMBER=3306
- MOODLE_DATABASE_USER=bn_moodle
- MOODLE_DATABASE_NAME=bitnami_moodle
- ALLOW_EMPTY_PASSWORD=yes
ports:
- '80:80'
- '443:443'
volumes:
- /Users/macbook/Code/Php/moodle-docker/moodle:/bitnami/gatto
- moodle_data:/bitnami
depends_on:
- mariadb
Remember: Your folder on host_folder must be acessible by docker daemon
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