记录下docker命令

以下命令在Linux上运行
docker客户端比较简单,直接在窗口输入docker查看所有命令:

docker

(base) [user@localhost Uni-Core-main]$ docker

Usage:  docker [OPTIONS] COMMAND

A self-sufficient runtime for containers

Options:
      --config string      Location of client config files (default "/home/user/.docker")
  -c, --context string     Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with "docker
                           context use")
  -D, --debug              Enable debug mode
  -H, --host list          Daemon socket(s) to connect to
  -l, --log-level string   Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
      --tls                Use TLS; implied by --tlsverify
      --tlscacert string   Trust certs signed only by this CA (default "/home/user/.docker/ca.pem")
      --tlscert string     Path to TLS certificate file (default "/home/user/.docker/cert.pem")
      --tlskey string      Path to TLS key file (default "/home/user/.docker/key.pem")
      --tlsverify          Use TLS and verify the remote
  -v, --version            Print version information and quit

Management Commands:
  app*        Docker App (Docker Inc., v0.9.1-beta3)
  builder     Manage builds
  ......
Commands:
  attach      Attach local standard input, output, and error streams to a running container
  build       Build an image from a Dockerfile
  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
  events      Get real time events from the server
  exec        Run a command in a running container
  export      Export a container's filesystem as a tar archive
  history     Show the history of an image
  images      List images
  import      Import the contents from a tarball to create a filesystem image
  info        Display system-wide information


docker command --help 查看指令的具体使用方法:

(base) [user@localhost Uni-Core-main]$ docker build --help

Usage:  docker build [OPTIONS] PATH | URL | -

Build an image from a Dockerfile

Options:
      --add-host list           Add a custom host-to-IP mapping (host:ip)
      --build-arg list          Set build-time variables
      --cache-from strings      Images to consider as cache sources
      --cgroup-parent string    Optional parent cgroup for the container
      --compress                Compress the build context using gzip
      --cpu-period int          Limit the CPU CFS (Completely Fair Scheduler) period
      --cpu-quota int           Limit the CPU CFS (Completely Fair Scheduler) quota
  -c, --cpu-shares int          CPU shares (relative weight)
      --cpuset-cpus string      CPUs in which to allow execution (0-3, 0,1)
      --cpuset-mems string      MEMs in which to allow execution (0-3, 0,1)
      --disable-content-trust   Skip image verification (default true)
  -f, --file string             Name of the Dockerfile (Default is 'PATH/Dockerfile')
      --force-rm                Always remove intermediate containers
      --iidfile string          Write the image ID to the file
      --isolation string        Container isolation technology
      --label list              Set metadata for an image
  -m, --memory bytes            Memory limit
      --memory-swap bytes       Swap limit equal to memory plus swap: '-1' to enable unlimited swap
      --network string          Set the networking mode for the RUN instructions during build (default "default")
      --no-cache                Do not use cache when building the image
      --pull                    Always attempt to pull a newer version of the image
  -q, --quiet                   Suppress the build output and print image ID on success
      --rm                      Remove intermediate containers after a successful build (default true)
      --security-opt strings    Security options
      --shm-size bytes          Size of /dev/shm
  -t, --tag list                Name and optionally a tag in the 'name:tag' format
      --target string           Set the target build stage to build.
      --ulimit ulimit           Ulimit options (default [])

docker pull 获取镜像

(base) [user@localhost Uni-Core-main]$ docker pull dptechnology/unimol:latest-pytorch1.11.0-cuda11.3
latest-pytorch1.11.0-cuda11.3: Pulling from dptechnology/unimol
d5fd17ec1767: Pull complete
aa1c1095ee01: Pull complete
4b5a4c7a4fbf: Pull complete
13352ad804a8: Pull complete
d3dba242f337: Pull complete
b8e20393c8a7: Pull complete
f36d862e19f9: Pull complete
527a82de0a82: Pull complete
bcf7babe7ac9: Pull complete
e4cee52b04df: Pull complete
1fc9cc7121fc: Pull complete
613c504c24df: Pull complete
4890eb5fdb95: Pull complete
74335c7dd040: Pull complete
48d07cd0ba01: Pull complete
c514570f50cc: Pull complete
fce8ed01eb0b: Pull complete
89fff5e792c4: Pull complete
538b5de1f21f: Pull complete
ded59de7bf96: Pull complete
13360649e349: Pull complete
fa9974269d9d: Pull complete
e41c75bada03: Pull complete
0ec0e2438c63: Pull complete
10883ba8060f: Pull complete
Digest: sha256:cdb018f769fefdcff246e5d25e31d92f24b2f1c7042a335addbf6540f25af7e4
Status: Downloaded newer image for dptechnology/unimol:latest-pytorch1.11.0-cuda11.3
docker.io/dptechnology/unimol:latest-pytorch1.11.0-cuda11.3

docker run 启动容器

docker run -it :交互式操作
docker run -itd :放到后台运行
退出终端,直接输入 exit 即可

(base) [user@localhost Uni-Core-main]$ docker images # 显示镜像
REPOSITORY            TAG                               IMAGE ID       CREATED         SIZE
dptechnology/unimol   latest-pytorch1.11.0-cuda11.3     44cce66f1aa1   18 hours ago    15.6GB
<none>                <none>                            f508db8ae25c   5 months ago    4.64GB
mysql                 5.7                               09361feeb475   14 months ago   447MB
hello-world           latest                            d1165f221234   17 months ago   13.3kB
nvidia/cuda           11.1-cudnn8-runtime-ubuntu18.04   81a7b51c961c   20 months ago   4.64GB
nvidia/cuda           11.0-base                         2ec708416bb8   24 months ago   122MB
<none>                <none>                            718a6da099d8   2 years ago     448MB

(base) [user@localhost Uni-Core-main]$ docker run -it 44cce66f1aa1 /bin/bash
root@617c499d1c02:/# ls
NGC-DL-CONTAINER-LICENSE  bin  boot  dev  etc  home  lib  lib32  lib64  libx32  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
root@617c499d1c02:/# exit
exit
(base) [user@localhost Uni-Core-main]$

docker ps -a 查看所有的容器命令

(base) [user@localhost Uni-Core-main]$ docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS                      PORTS     NAMES
617c499d1c02   44cce66f1aa1   "/bin/bash"              3 minutes ago   Exited (0) 59 seconds ago             agitated_meninsky
6fd32d94899f   f508db8ae25c   "/bin/bash -c 'apt-g…"   5 months ago    Exited (100) 5 months ago             pensive_davinci
fe2d3012aa36   f508db8ae25c   "/bin/bash -c 'apt-g…"   5 months ago    Exited (100) 5 months ago             bold_buck
ddc5040d120b   f508db8ae25c   "/bin/bash -c 'apt-g…"   5 months ago    Exited (100) 5 months ago             elastic_curran

docker rm 删除容器

(base) [user@localhost Uni-Core-main]$ docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS                      PORTS     NAMES
e10da1b36b46   hello-world    "/hello"                 11 months ago   Exited (0) 11 months ago              unruffled_brahmagupta
d1ad1a357e06   hello-world    "/hello"                 11 months ago   Exited (0) 11 months ago              dreamy_jemison
695f53dedd8a   hello-world    "/hello"                 12 months ago   Exited (0) 12 months ago              clever_mayer
302620c7c2f3   hello-world    "/hello"                 12 months ago   Exited (0) 12 months ago              silly_mendeleev
ae14a6c71b7a   mysql:5.7      "docker-entrypoint.s…"   13 months ago   Exited (0) 27 minutes ago             mysql
(base) [user@localhost Uni-Core-main]$ docker rm -f e10da1b36b46
e10da1b36b46

docker rmi 删除镜像

(base) [user@localhost BYKY]$ docker rmi 09361feeb475
Untagged: mysql:5.7
Untagged: mysql@sha256:1a2f9cd257e75cc80e9118b303d1648366bc2049101449bf2c8d82b022ea86b7
Deleted: sha256:09361feeb4753ac9da80ead4d46e2b21247712c13c9ee3f1e5d55630c64c544f
Deleted: sha256:e454d1e47d2f346e0b2365c612cb6f12476ac4a3568ad5f62d96aa15bccf3e19
Deleted: sha256:e0457c6e331916c8ac6838ef4b22a6f62b21698facf4e143aa4b3863f08cf7d2
Deleted: sha256:ed73046ee2cd915c08ed37a545e1b89da70dc9bafeacfbd9fddff8f967373941
Deleted: sha256:419d7a76abf4ca51b81821da16a6c8ca6b59d02a0f95598a2605a1ed77c012eb
Deleted: sha256:9aecb80117a5517daf84c1743af298351a08e48fa04b8e99dcb63c817326a748
Deleted: sha256:d8773288899b1230986eba7486009df11d5dd6c628b1d4fd0443e873c6b00f70
Deleted: sha256:45a0a6bb39a4d7b37a6c598ae6af47f8a36ef63eaa9ef92d565137156aa36f54
Deleted: sha256:341f6b75346e72e9fa503aeb5362d1fe4f00449e02d3320e5c68f3052b7c2c13
Deleted: sha256:023f47f19f876ffa0225502a85b30954a44e54dc8223329fec32b336315c75c3
Deleted: sha256:058c443dffe18a5d2aad04cd5451a8540c7272ce9f8515d27e815303b1c25b59
Deleted: sha256:764055ebc9a7a290b64d17cf9ea550f1099c202d83795aa967428ebdf335c9f7

镜像运行过之后,要先删除容器,再删除镜像参考链接博文

docker images 列出主机上的镜像

(base) [user@localhost Uni-Core-main]$ docker images # 显示镜像
REPOSITORY            TAG                               IMAGE ID       CREATED         SIZE
dptechnology/unimol   latest-pytorch1.11.0-cuda11.3     44cce66f1aa1   18 hours ago    15.6GB
<none>                <none>                            f508db8ae25c   5 months ago    4.64GB
mysql                 5.7                               09361feeb475   14 months ago   447MB
hello-world           latest                            d1165f221234   17 months ago   13.3kB
nvidia/cuda           11.1-cudnn8-runtime-ubuntu18.04   81a7b51c961c   20 months ago   4.64GB
nvidia/cuda           11.0-base                         2ec708416bb8   24 months ago   122MB
<none>                <none>                            718a6da099d8   2 years ago     448MB

docker search 查找镜像

(base) [user@localhost Uni-Core-main]$ docker search unimol
NAME                  DESCRIPTION   STARS     OFFICIAL   AUTOMATED
dptechnology/unimol                 0
(base) [user@localhost Uni-Core-main]$ docker search alphafold2
NAME                                      DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
cford38/alphafold2_aml                    Running AlphaFold2 (from ColabFold) in Azure…   0
bs67/alphafold2                           alphafold2                                      0
godic97/alphafold2                                                                        0
niklastr/alphafold2                                                                       0
xiaoping514/alphafold2                                                                    0
site428/alphafold2                                                                        0
ibexcluster/alphafold2                                                                    0
dformoso/alphafold2                                                                       0
huangh0408/alphafold2_cuda101_conda_env                                                   0
athbaltzis/af2_proteinfold                Docker image to run AlphaFold2 using the nf-…   0
catherinekuhn17/alphafold220                                                              0
weinerm/alphafold                         nvidia/cuda:11.1-cudnn8-runtime-ubuntu18.04 …   0
ericmjl/alphafold2                                                                        0
mobiismlteam/alphafold2                                                                   0

docker cp 从宿主机拷贝到镜像中

(base) [user@localhost BYKY]$ docker cp UNK.smi 61974251a835:/home/DP5-master/UNK

拷贝文件夹时不需要加 -r

docker commit 保存镜像

运行一个镜像A,安装软件或者更新后,保存成另一个镜像B,B中就包含A中更新后的所有东西

(base) [user@localhost BYKY]$ docker commit -a "ligj" -m "DP4-AI" 61974251a835 dp4-ainmr:v1
sha256:d5cc877251b5e782068a53c9d209d40e8732637cb6a58a77e6280221be75a455
(base) [user@localhost BYKY]$ docker images
REPOSITORY            TAG                               IMAGE ID       CREATED         SIZE
dp4-ainmr             v1                                d5cc877251b5   9 seconds ago   28.5GB

docker commit 命令详解
-a :提交的镜像作者
-c :使用Dockerfile 指令来创建镜像
-m :提交时的说明文字
-p :在commit时,将容器暂停

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值