MayTheSchwartzBeWithYou MayTheSchwartzBeWithYou - 25 days ago 12
MySQL Question

Docker-compose: Copying files from local env to EC2 instance

Hello I have a configuration that builds docker containers for a flask app and a mysql instance.

I create a new VM with

docker-machine create -d amazonec2 --....... production


and then (after setting the correct environment)

docker-compose build
->
docker-compose up -d


The problem is that all these happen whilst CWD is a local repo with the files I need. It turns out these files are not copied over.

I have looked at docker cp and docker scp but it seems they do not solve the problem. E.g. with SCP I cannot reference the specific machine I need to copy the repo over (xow_web_1)

Here is the
.yml


web:
restart: always
volumes:
- .:/xow
build: .
ports:
- "80:80"
links:
- db
hostname: xowflask
command: python xow.py
db:
restart: always
hostname: xowmysql
image: mysql:latest
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: somepasswordhere
MYSQL_DATABASE: somedatabase
data:
restart: always
image: mysql:latest
volumes:
- /var/lib/mysql
command: "true"


How would be the most appropriate way to solve this? Is
docker-compose
the right approach? Looks awesome, but it doesn't solve an issue like this

Answer

The way we solved it in our organization is by using the COPY command to copy all of the data in the folder to the container. For example, copying all of the files from the current dir to the container /src folder will look like this -

### Copy Code
COPY . /src

It looks like you should add this line into the web container in your docker-compose configuration.