Public | Automated Build

Last pushed: 9 months ago
Short Description
A container with my basic dev tools running on Ubuntu.
Full Description

dev-container-base


(forked from https://github.com/dpetersen/dev-container-base)

A container with my basic dev tools running on Ubuntu. It does not have any languages or their
specific tools installed. This could be used as a base image for developing in a specific language.
Access is via SSH with the account coder, which has sudo.

Starting

The container exposes SSH and uses GitHub's public key
API
to add the keys for authorized users to
~/.ssh/authorized_keys for the coder account. You must specify all of the allowed GitHub
usernames as the AUTHORIZED_GH_USERS environment variable during docker run. Here's an example:

I start it like so:

docker run -d \
  -e AUTHORIZED_GH_USERS="jhillyerd,otherperson" \
  -p 0.0.0.0:31981:22 \
  jhillyerd/dev-container-base:latest

If the GitHub API is down or the user doesn't exist / has no keys, you'll get an error.

You'll probably want to add some volume mounts to that command, so that your code isn't cloned
inside of the container and potentially lost!

Step 3: profit.

Connecting

You have the running container, and now it's time to pair. Except you keep forgetting the IP address
and the port and the username, and you're sick of having to copy your SSH private key over to the
server. Do what the pros do and set up an alias! In ~/.ssh/config, add something like this:

Host devbox
  HostName <YOUR IP OR HOSTNAME>
  Port <YOUR MAPPED SSH PORT FROM ABOVE>
  User coder
  ForwardAgent true
# Feel free to leave this out if you find it unsafe. I tear down
# my dev box frequently and am sick of the warnings about the 
# changed host.
  StrictHostKeyChecking no
  UserKnownHostsFile=/dev/null

And now you may:

ssh devbox

And everything is magically handled for you! You may have to configure your SSH client to allow SSH
forwarding, but it will allow you to git push to private repositories without having to
authenticate every time, and without copying your key to the server (where it can be lost if the
container stops).

Development

Since I build images roughly once per year, I need to remind myself how to do it. A few Top Tips
below:

Building

docker build .

Did you update something that won't trigger a Dockerfile change, like push to your vimfiles? Use
the --no-cache flag.

Tagging

docker tag <YOUR SHA HERE> jhillyerd/dev-container-base:v1

Don't forget to tag latest! It's a manual process, not magic!

Pushing

docker push jhillyerd/dev-container-base
Docker Pull Command
Owner
jhillyerd
Source Repository

Comments (0)