Docker 实践指南(一)下载、配置及应用等常见命令

article/2025/10/2 6:16:42

一、下载及启动:

1、docker 启动

2、docker 删除

ubuntu中docker彻底卸载 - 饭米雪 - 博客园网上很多博主提供的命令行,其实并不能完全卸载docker。。。 #删除某软件及其安装时自动安装的所有包 sudo apt-get autoremove docker docker-ce docker-https://www.cnblogs.com/fmixue/p/15789202.html

二、常见操作:

1image

1.1 获取和列出镜像

# 获取镜像命令格式:docker pull [选项] [Docker Registry 地址[:端口号]/]仓库名[:标签]$ docker pull ubuntu:18.04
18.04: Pulling from library/ubuntu
92dc2a97ff99: Pull complete
be13a9d27eb8: Pull complete
c8299583700a: Pull complete
Digest: sha256:4bc3ae6596938cb0d9e5ac51a1152ec9dcac2a1c50829c74abd9c4361e321b26
Status: Downloaded newer image for ubuntu:18.04
docker.io/library/ubuntu:18.04# 运行查看
$ docker run -it --rm ubuntu:18.04 bashroot@e7009c6ce357:/# cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.1 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.1 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic# 列出镜像
$ docker image ls
REPOSITORY           TAG                 IMAGE ID            CREATED             SIZE
redis                latest              5f515359c7f8        5 days ago          183 MB
nginx                latest              05a60462f8ba        5 days ago          181 MB
mongo                3.2                 fe9198c04d62        5 days ago          342 MB
<none>               <none>              00285df0df87        5 days ago          342 MB
ubuntu               18.04               329ed837d508        3 days ago          63.3MB
ubuntu               bionic              329ed837d508        3 days ago          63.3MB

1.2 删除和上传镜像

1.3 dockerfile

1.4 image 其他操作

2 container

2.1 查看容器:

docker ps -a
docker container ls

(base) user@ubuntu:~$ docker ps --helpUsage:  docker ps [OPTIONS]List containersOptions:-a, --all             Show all containers (default shows just running)-f, --filter filter   Filter output based on conditions provided--format string   Pretty-print containers using a Go template-n, --last int        Show n last created containers (includes all states) (default -1)-l, --latest          Show the latest created container (includes all states)--no-trunc        Don't truncate output-q, --quiet           Only display container IDs-s, --size            Display total file sizes

2.2 创建及删除容器

(base) user@ubuntu:~$ docker run --helpUsage:  docker run [OPTIONS] IMAGE [COMMAND] [ARG...]Run a command in a new containerOptions:--add-host list                  Add a custom host-to-IP mapping (host:ip)-a, --attach list                    Attach to STDIN, STDOUT or STDERR--blkio-weight uint16            Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)--blkio-weight-device list       Block IO weight (relative device weight) 

2.2.1  常用创建命令

# docker run 命令格式: 
docker run [OPTIONS] IMAGE [COMMAND] [ARG...]$ docker run ubuntu:18.04 /bin/echo 'Hello world'
Hello world$ docker run -t -i ubuntu:18.04 /bin/bash
root@af8bae53bdd3:/## -i 交互使用,-t 显示容器运行终端。常常连在一起使用:-it

2.2.2 启动,终止,重启和删除容器容器


docker container start container_name    # 启动容器docker container stop container_name    # 终止容器docker container restart container_name    # 重启容器docker container rm container_name    # 删除容器# container_name :容器名

2.2.3 进/出容器

docker exec -it container_name docker attach  container_name # 在容器stdin中exit,退出容器后会终止容器# 退出时如果想继续运行:按顺序按【ctrl+p】,【ctrl+q】
# 如果不想继续运行:按【ctrl+d】或输入exit

2.2.4 导出导入容器 : (待续ing)

2.2. 5 容器重命名等其他命令

(base) user@ubuntu:~$ docker container --helpUsage:  docker container COMMANDManage containersCommands:attach      Attach local standard input, output, and error streams to a running containercommit      Create a new image from a container's changescp          Copy files/folders between a container and the local filesystemcreate      Create a new containerdiff        Inspect changes to files or directories on a container's filesystemexec        Run a command in a running containerexport      Export a container's filesystem as a tar archiveinspect     Display detailed information on one or more containerskill        Kill one or more running containerslogs        Fetch the logs of a containerls          List containerspause       Pause all processes within one or more containersport        List port mappings or a specific mapping for the containerprune       Remove all stopped containersrename      Rename a containerrestart     Restart one or more containersrm          Remove one or more containersrun         Run a command in a new containerstart       Start one or more stopped containersstats       Display a live stream of container(s) resource usage statisticsstop        Stop one or more running containerstop         Display the running processes of a containerunpause     Unpause all processes within one or more containersupdate      Update configuration of one or more containerswait        Block until one or more containers stop, then print their exit codes

参考资料:前言 - Docker —— 从入门到实践

9Ubuntu Docker 安装 | 菜鸟教程Ubuntu Docker 安装 Docker Engine-Community 支持以下的 Ubuntu 版本: Xenial 16.04 (LTS) Bionic 18.04 (LTS) Cosmic 18.10 Disco 19.04 其他更新的版本…… Docker Engine - Community 支持上 x86_64(或 amd64)armhf,arm64,s390x (IBM Z),和 ppc64le(IBM..https://www.runoob.com/docker/ubuntu-docker-install.htmlUbuntu Docker 安装 Docker Engine-Community 支持以下的 Ubuntu 版本: Xenial 16.04 (LTS) Bionic 18.04 (LTS) Cosmic 18.10 Disco 19.04 其他更新的版本…… Docker Engine - Community 支持上 x86_64(或 amd64)armhf,arm64,s390x (IBM Z),和 ppc64le(IBM..https://www.runoob.com/docker/ubuntu-docker-install.htmlUbuntu Docker 安装 Docker Engine-Community 支持以下的 Ubuntu 版本: Xenial 16.04 (LTS) Bionic 18.04 (LTS) Cosmic 18.10 Disco 19.04 其他更新的版本…… Docker Engine - Community 支持上 x86_64(或 amd64)armhf,arm64,s390x (IBM Z),和 ppc64le(IBM..https://www.runoob.com/docker/ubuntu-docker-install.html


http://chatgpt.dhexx.cn/article/RCeSYBPe.shtml

相关文章

2022 rog 枪神6p Ubuntu20.04 AX211无线网卡 驱动无效

新买的电脑rog 枪神6p&#xff0c;装Ubuntu20.04.4&#xff0c;无线网卡是AX211 装20.04.1失败&#xff0c;装20.04.4成功 系统装好以后&#xff0c;没wifi驱动&#xff0c;右上角没有wifi 这是因为目前20.04 lts默认的内核是5.13&#xff0c;而根据https://wireless.wiki.k…

cmd文件闪退问题追踪办法

在日常中&#xff0c;经常会遇到一些.cmd文件双击打开的时候闪退的问题&#xff0c;这个时候我们看不到日志也无从看报错信息&#xff0c;因此很难分析问题&#xff0c;这个时候有个小技巧&#xff0c;找一个编辑器&#xff0c;如&#xff1a;Edit等&#xff0c;对cmd文件进行编…

cmd文件和bat文件的区别+一个的bat脚本+bat基础知识

一&#xff1a;cmd文件和bat文件的区别 cmd和bat文件都是批处理文件&#xff0c;都是靠cmd.exe解析执行&#xff0c;两者本质上没有区别&#xff0c;都是简单的文本编码方式&#xff0c;都可以用记事本创建、编辑和查看。两者所用的命令行代码也是共用的&#xff0c;只是cmd文…

cmd批量文件重命名

rename *.* asflh???.*cd 进入目录文件夹&#xff0c;对象是当前目录下的文件&#xff0c; . 表示所有格式的所有文件&#xff0c; asflh 添加asflh前缀&#xff0c;写在后面添加后缀 通配符*表示任意多个字符&#xff0c;?表示一个字符 -----------------------更新 fo…

CMD如何直接运行文件

CMD如何直接运行文件 方式一(简单粗暴):直接将写好的代码文件改后缀为.bat,然后双击运行方式二:打开cmd,然后将要执行的文件丢到cmd里,按回车就OK了方式三:运行某种类型的文件,使用start关键字文件的路径,或直接省略start C:\Users\DEll>start C:\Users\DEll\Desktop\conne…

windows cmd 查看文件目录树

windows cmd 查看文件目录树 tree /?&#xff1a;命令提示 tree&#xff1a;不输入任何参数&#xff0c;输出一棵目录树 不显示文件&#xff0c;只显示目录&#xff1b; D:. ├─ets │ ├─FormAbility │ ├─MainAbility │ │ └─pages │ ├─model │ └─Sec…

CMD文件详解与DSP存储空间

CMD文件详解与DSP存储空间 CMD的全称为链接命令配置文件。以ROM/FLASH和RAM两类存储器为对象&#xff0c;用户通过编写CMD文件&#xff0c;来管理和分配系统中的所有物理存储器和地址空间。DSP芯片的片内存储器&#xff0c;只要没有被出厂占用&#xff0c;用户都可以全权支配。…

cmd 执行html文件,cmd执行bat文件 cmd文件和bat文件有什么区别?

cmd怎么执行dos下的bat文件在文件目录直接输入bt4.bat就可以了。记住要输入完整的文件名,包换后缀名。比如:11.bat在D盘根目录:在D:\>后面直接输入11.bat 回车。 cmd下执行bat文件的命令 在cmd下执行bat文件的命令的命令 新建一个.bat批处理文件,文件命令为@ECHO OFF c…

CCS中CMD文件

CMD使用举例 技术栈提前认知 1. 如何查看CCS中编译器版本&#xff1f; 概述 TI官方例程分析 1. 在CMD文件中进行配置 //判断当前编译器当前版本,上面有提到如何查看编译器版本 #if __TI_COMPILER_VERSION__ > 15009000 #if defined(__TI_EABI__) //判断“输出格式”…

[DSP学习笔记]cmd文件的讲解

一、前言 在笔者学习F28335的过程中&#xff0c;发现网上少有对于cmd文件的讲解&#xff0c;而学习DSP&#xff0c;肯定是要编写或修改cmd文件的。故笔者基于自己的学习经验&#xff0c;给出了自己对于cmd文件的理解。 在正式开始学习cmd文件之前&#xff0c;我们首先需要知道…

QT 运行时出现U1077:“cl”返回代码“0x1”报错时的解决思路

作为一个萌新小白&#xff0c;在第一次给QT配置环境并运行时出现了如下错误 遇到这个问题时我上网查找解决办法&#xff0c;但是都没有用&#xff0c;我在这个问题上卡了两三天&#xff0c;试了各种方法&#xff01; 后来我无意中找到了解决办法&#xff0c;现分享给大家。 首…

0x1、寄存器

通用寄存器 8086的所有CPU都是16位的&#xff0c;可以存放两个字节。 AX、BX、CX、DX这四个寄存器通常用来存放数据&#xff0c;被称为通用寄存器。 因为8086CPU上一代都是8为的寄存器。 因此&#xff0c;为了兼容上一代寄存器&#xff0c;AX、BX、CX、DX这四个寄存器都是两个可…

·穷途末路之举·解决VirtualBox启动问题-Error relaunching VirtualBox VM process 5/terminated with exit code1(0x1)

近来需安装linux虚拟机进行一些学习&#xff0c;选择使用VM VirtualBox安装ubuntu系统。 VirtualBox配置完成之后&#xff0c;在启动时&#xff0c;报错&#xff0c;内容如下&#xff1a; “Failed to open a session for the virtual machine exit code 1 (0x1) – E_FAIL (0x…

WIN10设置计划任务执行报(0x1)调用的函数不正确或调用了未知函数

前提&#xff1a;此任务的exe在本地可以正常执行&#xff0c;同时在修改前可以使用计划任务定时执行。排除脚本问题及权限问题。 报错如图&#xff1a; 相比之前可以使用计划任务执行的脚本&#xff0c;新脚本增加了读取配置文件的操作。怀疑是读取不到配置文件导致。 通过查…

进制的转换

通常使用的基本数据类型是十进制的就是0&#xff0c;1&#xff0c;2&#xff0c;3&#xff0c;4&#xff0c;5&#xff0c;6&#xff0c;7&#xff0c;8&#xff0c;9&#xff0c;10&#xff0c;11&#xff0c;12............ 通过八进制表达就是 01&#xff0c;02&#xff0c…

【Python】初学者也可以实现的人脸识别系统-0x1

作者&#xff1a;20岁爱吃必胜客&#xff08;坤制作人&#xff09;&#xff0c;近十年开发经验, 跨域学习者&#xff0c;目前于海外某世界知名高校就读计算机相关专业。荣誉&#xff1a;阿里云博客专家认证、腾讯开发者社区优质创作者&#xff0c;在CTF省赛校赛多次取得好成绩。…

解决windows服务器上定时任务执行时报0x1错误,但是手动执行顺利完成

最近修改定时任务重新部署后&#xff0c;定时运行后运行结果为0x1&#xff0c;但是手动执行后&#xff0c;任务可以顺利完成。 windows官网解释如下&#xff1a; 0x0&#xff1a; 操作已成功完成 0x1&#xff1a; 调用的函数不正确或调用了未知函数。 因为手动可以执行&…

Windows定时执行.py文件报(0x1)错

Windows定时执行.py文件报&#xff08;0x1&#xff09;错 按照博客https://blog.csdn.net/David_jiahuan/article/details/99960427&#xff0c;创建定时任务后报错(0x1)如下图&#xff0c;在终端里运行py文件正常&#xff0c;排除代码问题。 在网上查资料&#xff0c;有因为是…

Windows计划任务出现0x1错误结果

Windows计划任务出现0x1错误结果 现象解决方法结果 现象 参考不少的文章&#xff0c;基本上都是说因为权限的问题&#xff0c;但试了N次都不行,仍然报0x1的错误结果&#xff0c;亲测解决方法说明如下&#xff1b; 1.脚本本身没问题&#xff0c;手动本地可以执行&#xff1b; 2…

JAVA关于基本数据类型之间进行强制转换底层剖析

1.什么是基本类型之间的强制转换 先来聊一聊基本类型 基本数据类型所占用的字节数表示数的范围整型byte1-128~127short2-32768~32767int4-2147483648&#xff5e;2147483647long8比int大浮点型float4 比long大double8比float大字符型char2布尔型boolean 基本类型之间的强制转换…