Docker Community Forums

Share and learn in the Docker community.

Dockerfile COPY file into right container

docker

(Prestigedev) #1

I have 2 docker containers. One running tomcat and the other running mysql. I want to copy a .sql file into the already existing “docker-entrypoint-initdb.d” folder of the mysql container.

I used the following command in my Dockerfile:

COPY test.sql /docker-entrypoint-initdb.d

After both containers are started I saw that the folder “docker-entrypoint-initdb.d” was created in my tomcat container and the test.sql was copied into it. The file isn’t copied where I need it to be. test.sql wasnt copied into the mysql container.

What can I do?

Here’s my docker-compose.xml:

version: "2"

services:
    db: 
        image: mysql
        environment:
            - MYSQL_ALLOW_EMPTY_PASSWORD="true"

    myapp:
        build: ./myapp
        ports:
            - 8080:8080
            - 3306:3306

(Prestigedev) #2

Here’s the solution: http://stackoverflow.com/questions/40769082/dockerfile-copy-file-into-right-container/40770768#40770768