2

I want to copy local script files to a remote host and run one of them. On a local host I would use these commands:

docker run -d python tail -f /dev/null
docker cp ./ <id>:/usr/local/bin/
docker exec <id> python /usr/local/bin/script.py

I'd like to add an additional command specifying IP and port of a remote machine

The official site suggests to use curl. There is a list of docker clients, but all of them are supposed to be used programmatically.

I'd prefer to run those commands from console or, to put them into a .bat file. Why is there an additional level of complexity introduced by curl/ setting a project in some language to run three commands? Does docker-toolbox allow to execute commands on a remote host?

user2136963
  • 2,526
  • 3
  • 22
  • 41

1 Answers1

1

The docker command line can work against remote Docker Engines in the same way as the local engine - it uses environment variables to specify the details of the API it should connect to.

docker-machine wraps this up neatly with the env command, but you can do it with the regular docker CLI by setting these variables:

DOCKER_HOST=tcp://192.168.99.101:2376
DOCKER_CERT_PATH=/Users/nathanleclaire/.docker/machines/.client
DOCKER_TLS_VERIFY=1

Using your own remote host address and certs.

By default the Docker Engine API isn't exposed to remote clients, so you'll need to configure it - Using TLS with the Docker Engine shows you how.

Elton Stoneman
  • 17,906
  • 5
  • 47
  • 44
  • I set up it on the server without encryption `DOCKER_OPTS='-H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock'` http://www.virtuallyghetto.com/2014/07/quick-tip-how-to-enable-docker-remote-api.html In windows, I ceated an environment variable `DOCKER_HOST`, set it to `tcp://my.ip.address:port` and restarted the toolbox. On start it prints "docker is configured to use the default machine with ip 192.168.99.100". The commands are executed on a local instance. – user2136963 Oct 28 '16 at 17:23
  • The toolbox terminal runs in its own user session, so you either need to set a system variable, or set the environment variable inside the toolbox terminal. – Elton Stoneman Oct 29 '16 at 10:53