0

Where is the user's home directory, specifically ~/.ssh, in a python3.* docker image?

I need to add a specific SSH key to an image so it can access a private git repo at run-time.

Articles like this explain how to do this, but it still depends on the underlying image, and I don't know what the "python" image is based on, since it doesn't conform to any standard Linux distro.

8
  • Strictly speaking, you can put the key anywhere; ~/.ssh is just the default location. You can adjust whatever command uses the key to look in a specific location. Commented Jun 25, 2021 at 18:29
  • 1
    That said, the standard Python image doesn't have any regular users, only root and various services accounts. /root/.ssh doesn't exist by default, but you can create it. Commented Jun 25, 2021 at 18:32
  • If you are using some other image, you'll have to give us more details about how the image was created. Commented Jun 25, 2021 at 18:33
  • You really don't want to copy ssh keys into an image, since it's very easy to read them back out. But the answers to the linked questions go through a lot of options (bind mounts, multi-stage builds, buildkit extension options, ...). Commented Jun 25, 2021 at 18:40
  • In the Docker Hub image pages like the one you link to, the version tags are links to their respective Dockerfiles. "Buster" images are Debian-based, "Alpine" ones are Alpine-based. Commented Jun 25, 2021 at 18:41

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.