Although only Docker commands are automatically executed in the remote Docker environment, you can programmatically execute any set of commands in the remote Docker environment by SSHing into it and chaining any subsequent commands to your shell command.
To SSH into the remote Docker environment, run
ssh remote-docker while SSH'd into any CircleCI job that uses
setup_remote_docker or execute it programmatically in a
run step. (Make sure the
setup_remote_docker step runs first, otherwise, your SSH command will fail!)
Chaining a command to this SSH command in a headless fashion, i.e., as part of your CircleCI job, could look something like:
run: | ssh remote-docker \ echo "this echo command will be executed in the remote Docker environment \
rather than the initial job container itself"
The challenge presented here is that only a singular command can be passed to the SSH shell—for example, if you run
ssh remote-docker touch file1 && touch file2,
file1 will be created in the remote Docker environment, but
file2will be created in your job's local container.
So, if you want to do run a more complex set of commands in the remote Docker environment, programmatically, then you need to find a way to have them be executed as a single command.
Some good approaches are outlined here:
These suggestions include using a "here document" or save your commands to a shell script which you then pipe into your
If you are using remote-docker commands to update your Docker storage driver, please checkout this helpful thread in our forum: