Granolaboy
Granolaboy

Reputation: 333

Nothing happens when copying file with Dockerfile

I use docker-compose for a simple keycloak container and I've been trying to install a new theme for keycloak. However I've been unable to copy even a single file to the container usnig a Dockerfile. The Dockerfile and docker-compose.yml are in the same directory

Neither of these commands work or cause any events or warnings in the logs.

COPY test /tmp/
COPY /home/adm/workspace/docker/keycloak-cluster/docker/kctheme/theme/login/. /opt/jboss/keycloak/themes/keycloak/login/

Copying manually with

sudo docker cp test docker_keycloak_1:/tmp

works without any issues.

Upvotes: 0

Views: 440

Answers (2)

Gerrit
Gerrit

Reputation: 881

Files have to be in the same directory or a subdirectory of the directory with your Dockerfile build file if you use COPY, and have to be present at build time. No absolute paths.

/tmp as destination is also a bit tricky, because the startup process of the container might have a /tmp cleanout, which means that you would never see that file in a running container.

Upvotes: 0

albttx
albttx

Reputation: 3794

Quick understanding on Docker.

docker build: Create an image from a Dockerfile

docker run: Create a container from an image.

(you can create yourself the image or use a existing image from docker hub )

Based on what you said, you have 2 options.

  • Create a new docker image based on the existing one and add the theme.

something like

# Dockerfile
FROM jboss/keycloak

COPY test /tmp/
COPY /home/adm/workspace/docker/keycloak-cluster/docker/kctheme/theme/login/. /opt/jboss/keycloak/themes/keycloak/login/

and then use docker build to create your new image

  • Volume the theme in the correct directory

using docker-compose volume

version: '3'
services:
  keycloak:
    image: quay.io/keycloak/keycloak:latest
    volumes:
      - "./docker/kctheme/theme/login:/opt/jboss/keycloak/themes/keycloak/login"

Upvotes: 1

Related Questions