I have a Docker container managed with Docker compose, which defines the
unless-stopped restart policy. But my container never starts after I reboot the machine. But it does restart if I just restart the Docker service. I have a similar setup on another machine which I have no issues with.
I kept on searching the issue until it hit me all of a sudden. I’m using secrets read from files. The files are in the
/tmp directory which gets cleared, thus the container fails to start.
When I defined the secrets files, I just threw them away from the source code repository, without thinking too much where. I wasn’t even sure if I was going to use them for a long time.
When defining a multi service environment with Docker and Docker Compose, the usual way was to use a Dockerfile for each service, starting with the base image and adding all custom needs:
RUN docker-php-ext-install opcache
ADD virtual-host.conf /etc/nginx/conf.d/default.conf
Then you could compose all services.
Then Docker 17.05 introduced multi-stage builds, allowing to use one Dockerfile. Continue reading Docker multi-stage builds with Docker Compose