Pass SSH key to docker

In my config.yml I add an SSH key with the - add_ssh_keys command.

How do I pass the keys to a docker container? I use the WordPress CLI docker container and I would like to do some operations with it that require ssh. But I can’t figure out how to pass the SSH key to my docker container that runs the WP CLI.

Are you running a remote docker engine, or are you doing this inside of a Virtual Machine image?

For the machine image, I’d suggest mounting the keys as a volume when you start up a container.

If you are using the remote docker engine, this will be much more difficult because there is no way to mount volumes in that scenario.

Initially I was using a machine executor. I mounted the ssh keys, however this let to a permission problem… so I switched to a standard circleci/php image and manually install wp cli. Seems to be an easy workaround.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.