MayTheSchwartzBeWithYou MayTheSchwartzBeWithYou - 2 months ago 21
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

restart: always
- .:/xow
build: .
- "80:80"
- db
hostname: xowflask
command: python
restart: always
hostname: xowmysql
image: mysql:latest
- "3306:3306"
MYSQL_ROOT_PASSWORD: somepasswordhere
MYSQL_DATABASE: somedatabase
restart: always
image: mysql:latest
- /var/lib/mysql
command: "true"

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


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.