Using dockerfile to extend base docker-compose installation

I have confirmed that the following command works:

$ sudo docker build -t nextcloud .
Sending build context to Docker daemon  687.1MB
Step 1/2 : FROM nextcloud:latest
 ---> 453a63c1def9
Step 2/2 : RUN apt-get update && apt-get install -y procps smbclient && rm -rf /var/lib/apt/lists/*
 ---> Running in 8321750abbfa
[...]
Successfully built b459f388c1ee
Successfully tagged nextcloud:latest

Next step is to add the config specified by @wwe to my docker-compose and test this.

First, here’s the docker-compose.yml file:

version: '3'

services:
  nextcloud:
    build:
      context: ${APPDATA}
      dockerfile: Dockerfile
    container_name: nextcloud
    restart: unless-stopped
    ports:
      - 8088:80
    environment:
      - MYSQL_HOST=mysql
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_PASSWORD=${PASSWORD}
    volumes:
      - ${APPDATA}/html:/var/www/html

  mysql:
    image: mysql:8.0
    restart: unless-stopped
    container_name: nextcloud_mysql
    environment:
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_PASSWORD=${PASSWORD}
      - MYSQL_ROOT_PASSWORD=${PASSWORD}
    volumes:
      - ${APPDATA}/mysql:/var/lib/mysql

volumes:
  mysql:
  nextcloud:

I have a .env file with the following name/value pairs:

APPDATA=/srv/nextcloud
PASSWORD=[password]

I have a Dockerfile with the following contents:

FROM nextcloud:latest

RUN apt-get update && apt-get install -y procps smbclient && rm -rf /var/lib/apt/lists/*

The following commands are issued:

$ sudo docker-compose up --detach
Creating network "nextcloud_default" with the default driver
Building nextcloud
Sending build context to Docker daemon  687.1MB
Step 1/2 : FROM nextcloud:latest
[...]
Step 2/2 : RUN apt-get update && apt-get install -y procps smbclient && rm -rf /var/lib/apt/lists/*
[...]
WARNING: Image for service nextcloud was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating nextcloud         ... done
Creating nextcloud_mysql ... done

Now when I access my Nextcloud host, I can see that the smbclient has been installed. This works, and will support upgrades!

1 Like