Reputation: 9082
I have noticed a pattern that is easily reproducible but I can not answer why for the life of me its happening. For some reason if I use the command docker-compose kill
(to kill all the containers), and then start it back up again with docker-compose -d
my web container gets stuck into an infinite loop of restarting. I have looked all over the internet for answers on this and could not find anything.
Looks something like below which shows the steps to see what is happening.
Please refer to this post I made (Docker-Compose won't volume my php.ini file) for my complete docker setup that is used here in the exact same way, but I'll attach my docker-compose file here for quick reference.
docker-compose.yml
version: '2'
services:
dblive:
image: mysql:5.5.52
volumes:
- ./db_data_live:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: ****
MYSQL_DATABASE: ****
MYSQL_USER: ****
MYSQL_PASSWORD: ****
dbdev:
image: mysql:5.5.52
volumes:
- ./db_data_dev:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD:****
MYSQL_DATABASE: ****
MYSQL_USER: ****
MYSQL_PASSWORD: ****
phpmyadmin:
depends_on:
- dblive
- dbdev
image: phpmyadmin/phpmyadmin
environment:
PMA_ARBITRARY : 1
restart: always
ports:
- "8081:80"
web:
build: ./
depends_on:
- dblive
- dbdev
volumes:
- ./web:/var/www
- ./config/custom.php.ini:/etc/php5/apache2/conf.d/custom.php.ini
- ./logs/apache_error.log:/var/log/apache2/error.log
- ./logs/apache_access.log:/var/log/apache2/access.log
- ./config/apache_default.conf:/etc/apache2/sites-enabled/000-default.conf
restart: always
ports:
- "80:80"
- "443:443"
Steps to Reproduce
docker-compose up -d
to start the containers again, and follow up with a docker ps every 5 seconds to notice the consistent restarting on the web container. Feel free to kill and restart many times and the restarting will keep happening.#-
./config/custom.php.ini:/etc/php5/apache2/conf.d/custom.php.ini
My question is why does changing the docker-compose.yml file slightly and then starting up cause it to work now? If I kill the container for any reason after this and try to start up again without making a change in the docker-compose.yml file then the restart loop occurs on the web container. Why is it doing this?
Attached below is an image showing it working after the previous restarts from the first image I attached. In the image please ignore and excuse the ERROR: yaml.scanner.ScannerError:
I forgot I had XX'ed out my MySQL passwords so make sure you just put something there to make it happy. The content after the error shows that it suddenly starts working again.
Upvotes: 1
Views: 4807
Reputation: 9082
The answer is to not use run docker-compose kill but use docker-compose down instead because docker-compose kill only kills the containers but does not clear the cache that docker-compose makes for you.
Upvotes: 3