docker使用说明

1 什么是docker

Docker 是一个快捷、轻便的系统级虚拟化技术,开发者和系统管理员可以使用它构建具备所有必要依赖项的应用程序。

2 docker安装

2.1 wsl ubuntu docker安装

  1. Docker for window桌面版安装[https://www.docker.com/products/docker-desktop/]
  2. 先卸载旧版,如果没有的话,就不用执行了,直接第3步
apt-get remove docker docker-engine docker.io containerd runc
  1. 安装必要的系统工具
apt update
apt-get install ca-certificates curl gnupg lsb-release
  1. 安装证书
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

  1. 写入软件源信息
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
  1. 安装
sudo apt-get install docker-ce docker-ce-cli containerd.io

2.2 linux docker安装

参照 《wsl ubuntu docker安装》2~6步。

2.3 Ubuntu docker离线安装

  1. 下载ubuntu的docker安装包
    下载路径:https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/
  2. 离线安装docker需要下载3个包,containerd.io ,docker-ce-cli,docker-ce
containerd.io_1.2.6-3_amd64.deb
docker-ce_19.03.9_3-0_ubuntu-xenial_amd64.deb
docker-ce-cli_19.03.9_3-0_ubuntu-xenial_amd64.deb
  1. pkg 命令安装,先安装 containerd.io 跟 docker-ce-cli,最后安装docker-ce
sudo dpkg -i containerd.io_1.4.6-1_amd64.deb
sudo dpkg -i docker-ce-cli_20.10.7_3-0_ubuntu-xenial_amd64.deb
sudo dpkg -i docker-ce_20.10.7_3-0_ubuntu-xenial_amd64.deb

2.4 docker启动验证

启动:sudo service docker start
版本查询:docker version
验证:docker run hello-world

root:/home/leo# sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
719385e32844: Pull complete
Digest: sha256:fc6cf906cbfa013e80938cdf0bb199fbdbb86d6e3e013783e5a766f50f5dbce0
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

3 docker使用

3.1 docker镜像加载

  1. 加载镜像
docker load < docker_image.tar
  1. 镜像查看和启动
查看本机镜像:docker images
$ docker images
REPOSITORY         TAG       IMAGE ID       CREATED        SIZE
xxx                          v4        a2bacfbb6dea   6 months ago   675MB
创建容器并启动:docker run 
$ docker run  -dit  -w /…/AP_SDK_SRC --name xx xxx /bin/bash
查看创建:docker ps
$  docker ps

3.2 docker进入

进入容器:
$ docker exec -it a2bacfbb6dea /bin/bash  或者  docker exec -it ap /bin/bash
停止容器:
sudo docker stop cd59258e881d
删除容器
docker container rm cd59258e881d
删除镜像
docker rmi 9c7a54a9a43c

3.23 docker镜像制作

请查阅相关资料,不在此文档展开。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值