Ubuntu Install Docker Things
This article is mainly explaining the basics of installing and using docker things, including docker-machine, docker-cli and description of docker deamon. These steps are executed on AWS EC2 ubuntu instance.
Install docker-machine
- go to Docker-Machine-Releases to copy the cmd and execute it.
here we use:
$ curl -L https://github.com/docker/machine/releases/download/v0.14.0/docker-machine-`uname -s`-`uname -m` >/tmp/docker-machine &&
chmod +x /tmp/docker-machine &&
sudo cp /tmp/docker-machine /usr/local/bin/docker-machine
- Remove tmp file.
$ rm /tmp/docker-machine
- Test:
$ docker-machine -v
- docker-machine 的指令列表:
docker-machine config
docker-machine env
docker-machine inspect
docker-machine ip
docker-machine kill
docker-machine provision
docker-machine regenerate-certs
docker-machine restart
docker-machine ssh
docker-machine start
docker-machine status
docker-machine stop
docker-machine upgrade
docker-machine url
Install docker-compose
Refer: https://docs.docker.com/compose/install/#install-compose
1. Run this command to download the latest version of Docker Compose:
sudo curl -L https://github.com/docker/compose/releases/download/1.20.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
2. Apply executable permissions to the binary:
sudo chmod +x /usr/local/bin/docker-compose
3. Test the installation.
docker-compose --version
Install docker
apt install docker.io
oryum install -y docker
Docker cmds
- 查看运行容器
docker ps
- 查看所有容器
docker ps -a
- 进入容器, 其中字符串为容器ID:
docker exec -it d27bd3008ad9 /bin/bash
- 停用全部运行中的容器:
docker stop $(docker ps -q)
- 删除全部容器:
docker rm $(docker ps -aq)
- 一条命令实现停用并删除容器:
docker stop $(docker ps -q) & docker rm $(docker ps -aq)
- 重启docker
systemctl restart docker
PS: Cmds
如何知道Ubuntu里安装了哪些软件?
在终端使用以下命令:
$ dpkg -l <appname>
如何卸载某个软件?
$ sudo apt-get --purge remove <programname>
purge表示彻底删除。如果想删除apt-get下载的某个软件安装包呢?
Ubuntu 中apt-get下载的安装包放在/var/cache/apt/archives里。所以可以在这个路径下删除。
或者使用以下命令:
$ apt-get autoclean
这个命令将已经删除了的软件包的.deb安装文件从硬盘中删除掉。$ apt-get clean
这会把你已安装的软件包的安装包也删除掉。