I am new to Docker and I am trying to figure out how to set the name of the created data volume. Currently, the directory is automatically called the long hash in / var / libs / docker, which is far from user-friendly.
I am trying to set up a development environment for MODX, as shown here: https://github.com/modxcms/docker-modx
Currently, my docker-compose.yml file looks like this:
web: image: modx links: - db:mysql ports: - 80:80 db: image: mysql environment: MYSQL_ROOT_PASSWORD: example ports: - 3306:3306 command: mysqld --sql-mode=NO_ENGINE_SUBSTITUTION myadmin: image: phpmyadmin/phpmyadmin links: - db:db ports: - 8080:8080
This works fine, but I'm not sure how to name the data volume that I would edit directly using my IDE.
(As a side question, do I need to create it in / var / libs / docker? Or is there a way to install it in a directory in my home folder?)
Update: Thanks to the help of @juliano, I updated the docker-compose.yml file to:
version: '2' services: web: image: modx volumes: - html:/home/muzzstick/dev/modxdev links: - db:mysql ports: - 80:80 db: image: mysql environment: MYSQL_ROOT_PASSWORD: example ports: - 3306:3306 command: mysqld --sql-mode=NO_ENGINE_SUBSTITUTION myadmin: image: phpmyadmin/phpmyadmin links: - db:db ports: - 8080:8080 volumes: html: external: false
Unfortunately, it looks like the web container is not running. db and myadmin containers show that they are working fine. There were no errors ... if I type docker start docker_web_1 , it will appear, but docker ps -a shows that it exited as soon as it started.
Update 2
Running docker-compose up -d without any problems. But then, as you can see below, the web container exits as soon as it is created.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a1dd6d8ac94e modx "/entrypoint.sh apach" 10 seconds ago Exited (1) 5 seconds ago docker_web_1 ee812ae858dc phpmyadmin/phpmyadmin "/run.sh phpmyadmin" 10 seconds ago Up 5 seconds 80/tcp, 0.0.0.0:8080->8080/tcp docker_myadmin_1 db496134e0cf mysql "docker-entrypoint.sh" 11 seconds ago Up 10 seconds 0.0.0.0:3306->3306/tcp docker_db_1
Update 3 OK The error logs for this container show:
error: missing MODX_DB_HOST and MYSQL_PORT_3306_TCP environment variables Did you forget to --link some_mysql_container:mysql or set an external db with -e MODX_DB_HOST=hostname:port?
This error occurs from https://github.com/modxcms/docker-modx/blob/master/apache/docker-entrypoint.sh#L15-L20
Could it be something like a link, handled differently in version 2 for docker?