It's possible to edit or create files on the remote docker environment with an ssh command.
Note that the -a in the tee command will append to a file if it exists, or create the file if it does not exist. In this example we are creating a daemon.json file in /etc/docker with configuration to use a registry-mirror. Then we execute sudo service docker restart on the remote environment to restart the docker daemon, which will pick up the new configuration. Then docker system info executes in the primary container, and will report the successful configuration of docker.
The strategy can be used for other services as well that need to be configured in the remote environment.
- image: circleci/python:3
cat \<< EOF | ssh remote-docker "sudo tee -a /etc/docker/daemon.json"
ssh remote-docker "sudo service docker restart"
docker system info