I'm trying to set up an SSH Key on my Docker container, which I'm deploying to Elastic Beanstalk. This question and answer has helped me a lot, but as I'm using Dockerized NodeJS and not NodeJS directly, the exact steps for copying in SSH keys don't really work for me.
I have a ssh_setup.config
file inside .ebextensions
, and right now I can copy my SSH key from my private S3 Bucket to /root/.ssh
; however, this is /root/.ssh
on my EC2 instance, and not inside of my Docker container. It's particularly difficult, because I can't figure out where the Docker container is actually being built (it seems to be a different directory every time, something like /var/lib/docker/tmp/docker-builder<number>/
or something like that).
I've tried this:
commands:
copy-git-token:
command: cp -R /root/.ssh/ ./ssh/
Which doesn't work - that copies into /opt/elasticbeanstalk/eb_infra
. I've also tried:
container_commands:
copy-git-token:
command: cp -R /root/.ssh/ ./ssh/
Which also doesn't work - that copies into /var/app/current
, but I've since found out that that only runs after the Docker container has already been built (hence too late).
From what I can tell, there are three main ways I can end up solving this:
1. Figure out how to copy a file into the Docker build directory, and then use COPY
to copy that into the Docker container; or
2. Figure out how to configure the docker build command, so as to use a --build-arg
or something of the sort to get my SSH key into the Docker container; or
3. Figure out how to retrieve the file from outside of the Docker build directory.
Any assistance on any of these three pathways (or others if they do exist, which I'm sure they do) would be greatly appreciated. The Elastic Beanstalk documentation on this is sorely lacking.
Thanks in advance.