Docker Commands

Table of Contents

Docker misc.


Install

Alpine

1
apk add docker docker-compose

Ubuntu

1
2
3
4
5
apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] http://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt update
apt install docker-ce docker-ce-cli containerd.io

Non-root

1
sudo adduser <user> docker

Import/Export Image

Manual

1
2
docker save -o <output tar> <image name>
docker load -i <tar file>

Push

Push from source to target.

1
docker save <image> | bzip2 | ssh user@host 'bunzip2 | docker load'

OR

1
docker save <image> | bzip2 | pv | ssh user@host 'bunzip2 | docker load'

Pull

1
ssh target_server 'docker save image:latest | bzip2' | pv | bunzip2 | docker load

docker-compose

Specify compose file

1
docker-compose -f <filename> up

Daemon mode

1
docker-compose -f <filename> up -d

This will also start compose container if docker is auto start during reboot.

Enter shell of running compose container

1
docker-compose -f <filename> exec <appname> sh
John Siu
Minimize the Effort, Maximize the Effect!
comments powered by Disqus