Docker: How to use a Dockerfile in addition to docker-compose.yml

  docker, docker-compose, nginx

I am using this repo to set up a local wordpress development environment:

I hijacked the docker-compose to change the nginx port, but also to try to install openssl and vim on the nginx server. But when I do a docker-compose up the nginx server never starts properly.

This is what i see:

CONTAINER ID   IMAGE                  COMMAND                  CREATED              STATUS                          PORTS                    NAMES
57cf3dff059f   nginx:latest           "bash"                   About a minute ago   Restarting (0) 14 seconds ago                            nginx

I tried to reference a Dockerfile inside the docker-compose like this:

    image: nginx:${NGINX_VERSION:-latest}
    container_name: nginx
      - '8085:8085'
      - '443:443'
    build: .
      - ${NGINX_CONF_DIR:-./nginx}:/etc/nginx/conf.d
      - ${NGINX_LOG_DIR:-./logs/nginx}:/var/log/nginx
      - ${WORDPRESS_DATA_DIR:-./wordpress}:/var/www/html
      - ${SSL_CERTS_DIR:-./certs}:/etc/letsencrypt
      - ${SSL_CERTS_DATA_DIR:-./certs-data}:/data/letsencrypt
      - wordpress
    restart: always

Notice the line that says "build: .".
Here’s the contents of my Dockerfile:

FROM debian:buster-slim
RUN apt-get update

# installing vim isn't necessary.  but just handy.
RUN apt-get -y install openssl
RUN apt-get -y install vim

Clearly, I’m doing something wrong. Maybe I should be defining tasks directly in the docker-compose for the nginx server?
I wanted to find a way to make a clean separation between our customizations and the original code. But maybe this isn’t possible.


Source: Docker Questions