This is development environment with Go & VsCode running through X11
1.1K
The Goal of this image is to have a portable development environment. We ship this image with at least some of common dev tools I used The image contains the following software:
The best way to work with this tool is to bind-mount you $HOME inside the container so that you will be
able to work on you file.
I prefer not to work as root inside the container, so I will create you user inside the container at startup.
You'll have to pass env variables MYUSERNAME, MYUID and MYGID so that when you edit files inside the container you'll have the sames rights as outside.
Simply pull image from docker Hub
docker pull sebmoule/docker-vscode
Or build from source
make build
There are 2 run Options :
Running the container with user's specified inside :
make runwhich runs : By running the following command you'll be able to start the container. I've added it to my bash aliases
alias vscode='docker rm vscode || true ; \
docker run -dti \
--net="host" \
--name=vscode \
-h vscode \
-e DISPLAY=$DISPLAY \
-e MYUID=$(id -u) \
-e MYGID=$(id -g) \
-e MYUSERNAME=$(id -un) \
-e SSH_AUTH_SOCK=$SSH_AUTH_SOCK \
-v $(dirname $SSH_AUTH_SOCK):$(dirname $SSH_AUTH_SOCK) \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v $HOME:$HOME \
-w $HOME \
sebmoule/docker-vscode'
with this alias, I remove and Recreate my container If not running. If my container vscode is already running, then it won't delete it neither create another one. I can just enter the container and start working.
Explain Parameters :
--net="host"-e $DISPLAY-v /tmp/.X11-unix:/tmp/.X11-unix-e MYUID=$(id -u) create user with your UID-e MYGID=$(id -g) create group with your GID-e MYUSERNAME=$(id -un) create user with you username-v ${HOME}:${HOME} We bind-mount our HOME so that we can works with our files and access at least to :
~/.bashrc ~/.Xauthority ~/.local/ .ssh ~/.gconf ~/.npm ~/.config/Code ~/.vscode ...GOPATH and PATH so that it can resolve on /usr/local/go/bin..config and .vscode-w $HOME set working directory to $HOME or whatever you like (your $GOPATH..)-e SSH_AUTH_SOCK=$SSH_AUTH_SOCK-v $(dirname $SSH_AUTH_SOCK):$(dirname $SSH_AUTH_SOCK)The entrypoint will create your user inside the container if you have passed the according Environment variables.
It will also install some of tools for developping in Golang
The command will do the following:
MYUID MYGID and MYUSERNAME<your-HOME-dir>/.vscodeGOPATH from your computer to the one in the container. This
assumes you have a single directory. If you have multiple directories in your
GOPATH, then see below how you can customize this to run correctly.When bind-mounting you Home into the Container it will execture your .bashrc inside the container.
This Tool when bind-mounting your $HOME inside the container will source your HOME/.bashrc file.
To work properly this file must at least contains :
...
#Add my PATH
export GOPATH=~/go
PATH=$PATH:~/bin:~/.local/bin/:$GOPATH/bin/:/usr/local/go/bin/
...
In order to know when I work inside the container or on my box, I have differentiate my bash Prompt with different colors :
# If we have MYUSERNAME we are in Docker
if [ -z "$MYUSERNAME" ]; then
#I am on my box
PS1="[\[\033[31m\]\u\[\033[00m\]@\[\033[35m\]\h\[\033[00m\]: \[\033[34m\]\w\[\033[00m\]]\[\033[00m\]$"
else
#I am in the container
PS1="[\[\033[34m\]\u\[\033[00m\]@\[\033[32m\]\h-in-docker\[\033[00m\]: \[\033[35m\]\w\[\033[00m\]]\[\033[00m\]$"
fi

Content type
Image
Digest
Size
606.8 MB
Last updated
almost 9 years ago
docker pull sebmoule/docker-vscode