Sometimes we need to add some application to pre-configured docker container. We can do this with “docker build” in a few easy steps.
Step 1. Create Dockerfile. In it add source docker container to add requsted application installation procedure. Sampe Dockerfile
FROM Caddy/Caddy:latest
# Install mtr
USER root
RUN yum update -y
RUN yum install -y mtr
Step 2. Build docker container from Dockerfile.
#docker build --tag caddy-with-mtr .
Step 3. Modify docker-compose.yml file. replace original image with new one, you build on previous step. Fragment of modified docker-compose.yml file
services:
caddy:
image: caddy-with-mtr:latest
restart: unless-stopped
Step 4. And finally start fresh-build docker container.
/usr/local/sbin/docker-compose -f /opt/docker/docker-compose.yml up -d