Reference & summary of docker best practices
- Docker
- Installation
- Debian
- Update the apt-get package index
- Install packages to use a repository over HTTPS
- Add Docker’s official GPG key
- Verify the fingerprint (last 8 characters)
- Setup the stable docker repository
- Update the apt-get package index
- Install docker
- Setup proxy
- Edit the file
/etc/default/docker
and modify the proxy settings
- Restart the docker service
- Run the hello-world image
- If not working
- Usage
- Build image with a custom name
- Docker compose
- Installation
- Debian
- Download latest package
- Apply executable permissions
- Test the installation
- Usage
- Sources
Docker
Installation
Debian
Update the apt-get package index
Install packages to use a repository over HTTPS
1
2
3
4
5
6
| sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common
|
Add Docker’s official GPG key
1
| curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | sudo apt-key add -
|
Verify the fingerprint (last 8 characters)
1
| sudo apt-key fingerprint 0EBFCD88
|
Setup the stable docker repository
1
2
3
4
| sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
$(lsb_release -cs) \
stable"
|
Update the apt-get package index
Install docker
1
2
3
4
| sudo apt-get install docker-ce # Latest version
apt-cache madison docker-ce # List available versions
# (use 2nd column as VERSION_STRING)
sudo apt-get install docker-ce=<VERSION_STRING> # Install specific version.
|
The Docker daemon starts automatically.
Setup proxy
Edit the file /etc/default/docker
and modify the proxy settings
Restart the docker service
Run the hello-world image
1
| sudo docker run hello-world
|
If not working
1
2
3
4
| /etc/systemd/system/docker.service.d/http-proxy.conf
/etc/systemd/system/docker.service.d/https-proxy.conf
sudo systemctl daemon-reload # Flush changes
sudo systemctl restart docker # Restart docker service
|
Usage
Build image with a custom name
1
| docker build -t customName .
|
Docker compose
Installation
Debian
Download latest package
1
| sudo curl -L https://github.com/docker/compose/releases/download/1.16.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
|
Apply executable permissions
1
| sudo chmod +x /usr/local/bin/docker-compose
|
Test the installation
1
2
| $ docker-compose --version
docker-compose version 1.16.1, build 1719ceb
|
Usage
todo
Sources
Get Docker CE for Debian
RHD Blog - 10 things to avoid in docker containers
@rafabene - twitter