SSH Command
It's possible to edit or create files on the remote docker environment with an ssh command.
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.
version: 2.1
jobs:
build:
docker:
- image: circleci/python:3
steps:
- setup_remote_docker:
version: "19.03.8"
- run:
command: |
cat \<< EOF | ssh remote-docker "sudo tee -a /etc/docker/daemon.json"
{
"registry-mirrors": ["https://mirror.gcr.io"]
}
EOF
ssh remote-docker "sudo service docker restart"
docker system info
Note: The -a in the tee command will append to a file if it exists, or create the file if it does not exist.
This strategy can be used for other services that need to be configured in the remote environment as well.
Comments
Article is closed for comments.