Linux环境下Docker的安装和基本使用

使用环境:ubuntu18.0.4

1.安装Docker

sudo apt-get update
sudo apt-get install docker.io
sudo ln -sf /usr/bin/docker.io /usr/local/bin/docker

    解释:

    更新软件库

    apt-get 安装docker

    将docker.io可执行文件链接到/usr/local/bin/docker 并使用

2.Docker的基本使用

    2.1使用search 命令搜索镜像

unclej@unclej-HP-ProBook-4326s:~$ sudo docker search ubuntu
NAME                                                      DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
ubuntu                                                    Ubuntu is a Debian-based Linux operating sys…   8326                [OK]                
dorowu/ubuntu-desktop-lxde-vnc                            Ubuntu with openssh-server and NoVNC
            215                                     [OK]
......
......


smartentry/ubuntu                                         ubuntu with smartentry                          0                                       [OK]
1and1internet/ubuntu-16-healthcheck                       ubuntu-16-healthcheck                           0                                       [OK]
pivotaldata/ubuntu-gpdb-dev                               Ubuntu images for GPDB development              0                                       
ossobv/ubuntu                                             Custom ubuntu image from scratch (based on o…   0  

    结果显示以ubuntu为关键词的搜索结果

    2.2使用pull下载镜像

unclej@unclej-HP-ProBook-4326s:~$ sudo docker pull ubuntu
Using default tag: latest
latest: Pulling from library/ubuntu
124c757242f8: Already exists 
2ebc019eb4e2: Already exists 
dac0825f7ffb: Already exists 
82b0bb65d1bf: Already exists 
ef3b655c7f88: Already exists 
Digest: sha256:72f832c6184b55569be1cd9043e4a80055d55873417ea792d989441f207dd2c7
Status: Downloaded newer image for ubuntu:latest

     2.3images 列出镜像目录

unclej@unclej-HP-ProBook-4326s:~$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              latest              16508e5c265d        13 days ago         84.1MB
hello-world         latest              2cb0d9787c4d        8 weeks ago         1.85kB

    2.4 run 创建容器

sudo docker run -i -t --name hello ubuntu /bin/bash

    其中-i(interactive)指定为交互模式,即可输入;-t(Pseudo-tty)为其分配一个terminal;--name指定容器的名字,若不指定则Docker自动生成

    2.5 ps 查看容器列表

sudo docker ps -a

    其中-a参数使同时列出已终止的容器,否则只列出当前运行的容器

   2.6 start 启动容器

sudo docker start hello

   再用ps命令查看运行中的容器检验

    2.7 attach 连接容器

sodu docker attach hello

    2.8 stop停止容器

sudo docker stop hello

 

 

 

 

 

 

  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值