ubuntu16 docker

       

docker安装

环境: 阿里云 ubuntu16.04 _x64 root 用户权限
参考教程
1、查看环境,更新 apt 包索引。我喜欢root用户

apt-get update
apt-get -y install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
apt-get -y update
apt-get -y install docker-ce
 

2、有一条更简单的命令
这里Linus是我的用户名

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
usermod -aG docker linus

安装完毕后,下载Ubuntu镜像,我选择最新的,因为它很小,压缩后大约20多M
Ubuntu 镜像库地址

docker pull ubuntu:latest

查看镜像,docker images

docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              latest              bb0eaf4eee00        16 hours ago        72.9MB

运行和查看

linus@ubuntu:~$  docker run -itd --name ubuntu-test ubuntu /bin/bash
67bd4c63a9a58f8cc6b08be53a736c7d46a02844afa6a3d01bfc3861ff02a0d2
linus@ubuntu:~$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
67bd4c63a9a5        ubuntu              "/bin/bash"         11 seconds ago      Up 10 seconds                           ubuntu-test

停止运行

linus@ubuntu:~$ docker stop ubuntu-test
ubuntu-test

3、重新制作镜像–安装gosu
     docker gosu 官网链接,进去寻找我们需要的Dockerfile
在这里插入图片描述
从这里看,简单明了,真是好用,复制下来
在这里插入图片描述
创建目录

#创建docker目录,方便管理
mkdir docker
cd docker/

mkdir ubuntu
#vim 创建复制保存wq退出
vim ubuntu/latest.Dockerfile
# auto generated
# docker build -t gosu/ubuntu:latest -f ubuntu/latest.Dockerfile .
FROM ubuntu:latest
COPY --from=gosu/assets /opt/gosu /opt/gosu
RUN set -x \
    && /opt/gosu/gosu.install.sh \
    && rm -fr /opt/gosu

#运行,这个过程怎么好说,我第一次用ubuntu14.04只花了几分钟,这次用ubuntu:latest耗时很久
docker build -t gosu/ubuntu:latest -f ubuntu/latest.Dockerfile .  
#查看镜像
dockers images
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值