5

The usage scenario is like this:

I have an AWS EC2 instance already provisioned with docker-machine.

I want to use docker-compose to remotely start a few containers on that EC2 instance.

The compose file has a section like this:

  nginx-proxy:
    image: jwilder/nginx-proxy
    container_name: nginx-proxy
    ports:
      - "8888:80"
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - /home/ubuntu/nginx.tmpl:/app/nginx.tmpl:ro

If I use docker-compose up -d locally, it'll work, since the "/home/ubuntu/nginx.tmpl" file is present on my local machine.

But if I try to use docker-compose to control the remote daemon in AWS like this:

export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://x.y:2376"
export DOCKER_CERT_PATH="somedir"
docker-compose up -d

It'll fail, since the "/home/ubuntu/nginx.tmpl" file is not present in the remote machine.

I have tried creating such a file in the remote machine under the same directory, it works, but it feels wrong ... ...

What is a better way to mount a local file to a remote docker daemon?

Cui Pengfei 崔鹏飞
  • 8,017
  • 6
  • 46
  • 87

1 Answers1

1

Docker Machine has an scp command, so you can copy a local file to a remote machine and vice versa:

 docker-machine scp ~/my/local/nginx.tmpl machine-name:/home/ubuntu/nginx.tmpl

Here's the reference docs.

Elton Stoneman
  • 17,906
  • 5
  • 47
  • 44
  • I am actually going to be running that command from my CI server. I found out that running scp would require my private key, which I don't want to upload to jenkins – Cui Pengfei 崔鹏飞 Sep 19 '16 at 14:02