我是靠谱客的博主 怕孤单香氛,最近开发中收集的这篇文章主要介绍Docker 实践指南(一)下载、配置及应用等常见命令一、下载及启动:二、常见操作:,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

一、下载及启动:

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 bash

root@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 --help

Usage:  docker ps [OPTIONS]

List containers

Options:
  -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 --help

Usage:  docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

Run a command in a new container

Options:
      --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 --help

Usage:  docker container COMMAND

Manage containers

Commands:
  attach      Attach local standard input, output, and error streams to a running container
  commit      Create a new image from a container's changes
  cp          Copy files/folders between a container and the local filesystem
  create      Create a new container
  diff        Inspect changes to files or directories on a container's filesystem
  exec        Run a command in a running container
  export      Export a container's filesystem as a tar archive
  inspect     Display detailed information on one or more containers
  kill        Kill one or more running containers
  logs        Fetch the logs of a container
  ls          List containers
  pause       Pause all processes within one or more containers
  port        List port mappings or a specific mapping for the container
  prune       Remove all stopped containers
  rename      Rename a container
  restart     Restart one or more containers
  rm          Remove one or more containers
  run         Run a command in a new container
  start       Start one or more stopped containers
  stats       Display a live stream of container(s) resource usage statistics
  stop        Stop one or more running containers
  top         Display the running processes of a container
  unpause     Unpause all processes within one or more containers
  update      Update configuration of one or more containers
  wait        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

最后

以上就是怕孤单香氛为你收集整理的Docker 实践指南(一)下载、配置及应用等常见命令一、下载及启动:二、常见操作:的全部内容,希望文章能够帮你解决Docker 实践指南(一)下载、配置及应用等常见命令一、下载及启动:二、常见操作:所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(41)

评论列表共有 0 条评论

立即
投稿
返回
顶部