ubuntu下docker常见指令

1.开机自启动
sudo systemctl enable docker

2.运行/停止/重启/查看docker环境
sudo systemctl start docker
sudo systemctl stop docker
sudo systemctl restart docker
sudo systemctl status docker

3.创建并运行一个docker容器
sudo docker run hello-world
sudo docker run -it --name=my_ubuntu_container ubuntu /bin/bash
-it:交互式启动
--name:容器名字为my_ubuntu_container
image镜像:ubuntu
command:/bin/bash

4.列出正在运行/所有的docker容器
sudo docker ps
sudo docker ps -a

5.启动/进入容器(exit退出容器,但容器不会关闭)
sudo docker start 容器名或ID
sudo docker exec -it 容器名或ID /bin/bash

6.停止/删除一个docker容器
sudo docker stop container_id/names
sudo docker rm container_id/names

7.从docker hub拉取镜像
sudo docker pull 镜像名字

8.列出本地所有的docker镜像
sudo docker images

9.删除一个docker镜像
sudo docker rmi image_id

10.构建一个docker镜像
sudo docker build -t image_name .

11.将Docker容器的数据备份到本地
sudo docker commit container_id repository/image_name:tag

12.将Docker镜像推送到Docker Hub
sudo docker push repository/image_name:tag

13.保存容器更改并转换成新的镜像
docker commit my_ubuntu_container my_custom_ubuntu_image

14.导入导出容器
sudo docker export 容器ID > 文件名.tar
cat 文件名.tar | docker import - 镜像用户/镜像名:镜像版本号
(cat ubuntu.tar | docker import - ubuntu:1.0.0)

相关推荐

  1. ubuntudocker常见指令

    2024-03-28 06:34:01       40 阅读
  2. Ubuntu Docker安装 2024

    2024-03-28 06:34:01       27 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-28 06:34:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-28 06:34:01       101 阅读
  3. 在Django里面运行非项目文件

    2024-03-28 06:34:01       82 阅读
  4. Python语言-面向对象

    2024-03-28 06:34:01       91 阅读

热门阅读

  1. 什么是数据仓库

    2024-03-28 06:34:01       47 阅读
  2. react 简单的demo

    2024-03-28 06:34:01       44 阅读
  3. 什么是函数指针?如何定义和使用函数指针?

    2024-03-28 06:34:01       38 阅读
  4. 井字棋游戏(最大最小搜索+Alpha-Beta剪枝)

    2024-03-28 06:34:01       45 阅读
  5. Ubuntu16.04 切换系统python和gcc版本

    2024-03-28 06:34:01       41 阅读
  6. 添加图像MFC PDF

    2024-03-28 06:34:01       38 阅读
  7. git merge 和 git rebase

    2024-03-28 06:34:01       44 阅读
  8. pulsar: 批量接收消息

    2024-03-28 06:34:01       43 阅读
  9. 数据结构奇妙旅程之深入解析归并排序

    2024-03-28 06:34:01       46 阅读
  10. C 指针数组

    2024-03-28 06:34:01       37 阅读