docker ce on Ubuntu

Note:

# - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ - requires given linux commands to be executed as a regular non-privileged user

1. install

$sudo apt install docker.io

2. enable

$ sudo systemctl start docker
$ sudo systemctl enable docker

 test:

$ docker --version

 二、Docker compose

1. down

sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

2. exec

sudo chmod +x /usr/local/bin/docker-compose

test

tdtc@tdtc306:~$ docker-compose --version
docker-compose version 1.27.4, build 4667896b

 三、other command

    1. 清理image

sudo docker system prune -a

    2. 管理image

1)ps

sudo dokcer ps

2)进入container

fat shell:

sudo docker exec -it <mycontainer-names> bash

simple shell:

sudo docker exec -it <mycontainer-names> sh

3)container内执行

    查看

cat Gopkg.toml |more

    编辑

apt-get update
apt-get install vim -y vi Gopkg.toml

 4) stop all containers

sudo docker stop $(sudo docker ps -q)

Reference:

    1. How to Install Docker On Ubuntu 18.04 Bionic Beaver

    2. Install Docker Compose(Offical)

    3. How do I get into a Docker container's shell?

原文地址:https://www.cnblogs.com/xiaobin-hlj80/p/12907648.html