Make a simple project with docker
and help to learn the basics.
This project will make 2 containers: 1 app & 1 datastore(redis). The app will get data from redis and show it in the response. For redis image, we can download it from the official docker registry, but for app image, we will make it by ourself. The language to make the app is Golang
aka Go
.
You can use another language than Go
, but this project will focus on using Go
.
- OS: Ubuntu 16.04.6 LTS
- Docker: Docker version 18.09.7, build 2d0083d (Docker Engine - Community)
- Docker-Compose: docker-compose version 1.24.1, build 4667896b
- Docker-Machine: docker-machine version 0.16.0, build 702c267f
- Golang: go version go1.13 linux/amd64
- redis:6.0.9
- go:1.11
- verlandz/docker-app:1.0 -> we'll create this
It's a common pratice to not use latest tag
- Install docker
- Install docker-compose
- Install docker-machine
- Install golang (except go1.11)
- Basic golang
- Basic cmd redis
Usually docker need to be super user, so try to sudo su -
first.
FAQ
Q: Why we need to install go to our device if we can pull go image to our docker ?
A: The reason is for comparison version. So in docker, we're using go1.11 but in local we're using another version. Also having install go in your device make a guarantee that you understand how to manage GOPATH
and GOROOT
, we need it to undestand for dockerfile
.
You can follow from this docs
If you don't see root@verlandz
in sample cmd, that's mean it's not running on the root