Skip to content

Instantly share code, notes, and snippets.

@codelitt
Last active August 29, 2015 14:13
Show Gist options
  • Save codelitt/6883865bd0f64f2352d7 to your computer and use it in GitHub Desktop.
Save codelitt/6883865bd0f64f2352d7 to your computer and use it in GitHub Desktop.
Setting up docker for Go
#Build image from Dockerfile in same directory.
docker build --rm=true -t go_playground .
#Run docker image in a container with interactive shell connecting /go on my host machine to /go in docker container
# has name go-playgound and is ran from image go_playground.
sudo docker run -ti -p 9000:9000 -v /home/cody/projects/go:/go --name=go-playground go_playground /bin/bash -l
#Turns out that you don't need we don't need bin/bash. Line 52 in the dockerfile does that
#with no command at the end, it automatically uses what's in CMD in the docker file.
#Sometimes you still have to add the command on my setup for some reason though
sudo docker run -ti -p 9000:9000 -v /home/cody/projects/go:/go --name=go-playground go_playground
#Dev environment for an app for example
# Msql
sudo docker run --name ku-mysql -e MYSQL_ROOT_PASSWORD=password -d mysql
#attaching app to it
sudo docker run -ti -p 8888:8888 -v /home/cody/projects/go:/go --name ku-app --link ku-mysql:mysql -d go_playground
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment