其他分享
首页 > 其他分享> > Docker常用操作

Docker常用操作

作者:互联网

[root@localhost ~]# docker pull centos
Using default tag: latest
latest: Pulling from library/centos
[root@localhost ~]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
hello-world   latest    feb5d9fea6a5   4 months ago   13.3kB
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE         COMMAND    CREATED         STATUS                     PORTS     NAMES
0ab3a4609ecc   hello-world   "/hello"   4 minutes ago   Exited (0) 4 minutes ago             sleepy_turing
[root@localhost ~]# docker rm 0ab3a4609ecc
0ab3a4609ecc
[root@localhost ~]# docker rmi -f $(docker images -qa)
Untagged: hello-world:latest
Untagged: hello-world@sha256:97a379f4f88575512824f3b352bc03cd75e239179eea0fecc38e597b2209f49a
Deleted: sha256:feb5d9fea6a5e9606aa995e879d862b825965ba48de054caab5ef356dc6b3412
[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
centos       latest    5d0da3dc9764   5 months ago   231MB
[root@localhost ~]# docker run -it 5d0da3dc9764
[root@3dd0a3a9cca4 /]# 
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND       CREATED         STATUS                     PORTS     NAMES
3dd0a3a9cca4   5d0da3dc9764   "/bin/bash"   2 minutes ago   Exited (0) 2 minutes ago             loving_beaver
2a40735a772a   feb5d9fea6a5   "/hello"      7 minutes ago   Exited (0) 7 minutes ago             exciting_buck
[root@localhost ~]# docker start 3dd0a3a9cca4
3dd0a3a9cca4
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE          COMMAND       CREATED         STATUS              PORTS     NAMES
3dd0a3a9cca4   5d0da3dc9764   "/bin/bash"   4 minutes ago   Up About a minute             loving_beaver
[root@localhost ~]# docker stop 3dd0a3a9cca4
3dd0a3a9cca4
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND       CREATED         STATUS                     PORTS     NAMES
3dd0a3a9cca4   5d0da3dc9764   "/bin/bash"   5 minutes ago   Exited (0) 4 seconds ago             loving_beaver
[root@localhost ~]# docker rm 3dd0a3a9cca4
3dd0a3a9cca4
[root@localhost ~]# docker ps -qa|xargs docker rm
2a40735a772a
root@localhost ~]# docker run -d centos /bin/sh -c "while true;do echo hello ztf;sleep 2;done"
60a42445f78cbea48f1d23971575084986aee9853255ec9766c9de31094e2f69
[root@localhost ~]# docker logs 60a42445
hello ztf
hello ztf
[root@localhost ~]# docker top 60a42445
UID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD
root                3115                3097                0                   23:52               ?                   00:00:00            /bin/sh -c while true;do echo hello ztf;sleep 2;done
root                3186                3115                0                   23:53               ?                   00:00:00            /usr/bin/coreutils --coreutils-prog-shebang=sleep /usr/bin/sleep 2
[root@localhost ~]# docker inspect 60a42445
[
    {
        "Id": "60a42445f78cbea48f1d23971575084986aee9853255ec9766c9de31094e2f69",
        "Created": "2022-02-19T15:52:08.782734158Z",
[root@localhost ~]# docker cp 60a42445f78c:/tmp/ks-script-4luisyla  .
[root@localhost ~]# docker run -d -p 8080:8080 tomcat
8477d8fd9c51233285a2a77831e7a3bb41d87e790180632825e7a5ec34c5320a

标签:ago,常用,hello,mysql,操作,Docker,root,docker,localhost
来源: https://www.cnblogs.com/scau-zeng/p/15914352.html