ubuntu下安装和使用docker
source link: https://segmentfault.com/a/1190000038753220
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
ubuntu下安装和使用docker
Docker 是一个开源的应用容器引擎,基于 Go 语言 并遵从 Apache2.0 协议开源。
Docker 可以让开发者打包他们的应用以及依赖包到一个轻量级、可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化。
容器是完全使用沙箱机制,相互之间不会有任何接口(类似 iPhone 的 app),更重要的是容器性能开销极低。
Docker 从 17.03 版本之后分为 CE(Community Edition: 社区版) 和 EE(Enterprise Edition: 企业版),我们用社区版就可以了。
更新ubuntu的apt源索引
sudo apt-get update
安装包允许apt通过HTTPS使用仓库
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
添加Docker官方GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
设置Docker稳定版仓库
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
添加仓库后,更新apt源索引
sudo apt-get update
安装最新版Docker CE(社区版)
sudo apt-get install docker-ce
进入root权限
su root
- 输入本机密码
docker images
查看当前运行容器
docker ps
查看当前运行容器以及失效容器
docker ps -a
检查Docker CE是否安装正确
sudo docker run hello-world
启动docker
sudo service docker start
停止docker
sudo service docker stop
重启docker
sudo service docker restart
docker安装后默认开启,可以直接使用~~
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK