BetterManEddy

导航

 

常用参数:

-i : 保持打开stdin,交互式

-t : 分配一个TTY终端

-d : 后台运行,并显示容器ID

-p 主机端口:容器端口

-P IP::容器端口(随机端口)

--name:指定容器名称

-h:指定容器主机名

-v:将本地目录挂载到容器中,实现数据持久化

-a:查看所有容器,默认不显示已退出的容器

-q:只显示容器ID

官方文档参数:

-a, --attach=[]             Attach to STDIN, STDOUT or STDERR
--add-host=[]               Add a custom host-to-IP mapping (host:ip)
--blkio-weight=0            Block IO (relative weight), between 10 and 1000
-c, --cpu-shares=0          CPU shares (relative weight)
--cap-add=[]                Add Linux capabilities
--cap-drop=[]               Drop Linux capabilities
--cgroup-parent=            Optional parent cgroup for the container
--cidfile=                  Write the container ID to the file
--cpu-period=0              Limit CPU CFS (Completely Fair Scheduler) period
--cpu-quota=0               Limit the CPU CFS quota
--cpuset-cpus=              CPUs in which to allow execution (0-3, 0,1)
--cpuset-mems=              MEMs in which to allow execution (0-3, 0,1)
-d, --detach=false          Run container in background and print container ID
--device=[]                 Add a host device to the container
--dns=[]                    Set custom DNS servers
--dns-search=[]             Set custom DNS search domains
-e, --env=[]                Set environment variables
--entrypoint=               Overwrite the default ENTRYPOINT of the image
--env-file=[]               Read in a file of environment variables
--expose=[]                 Expose a port or a range of ports
-h, --hostname=             Container host name
--help=false                Print usage
-i, --interactive=false     Keep STDIN open even if not attached
--init=                     Run container following specified init system container method (systemd)
--ipc=                      IPC namespace to use
-l, --label=[]              Set meta data on a container
--label-file=[]             Read in a line delimited file of labels
--link=[]                   Add link to another container
--log-driver=               Logging driver for container
--log-opt=[]                Log driver options
--lxc-conf=[]               Add custom lxc options
-m, --memory=               Memory limit
--mac-address=              Container MAC address (e.g. 92:d0:c6:0a:29:33)
--memory-swap=              Total memory (memory + swap), '-1' to disable swap
--name=                     Assign a name to the container
--net=bridge                Set the Network mode for the container
--oom-kill-disable=false    Disable OOM Killer
-P, --publish-all=false     Publish all exposed ports to random ports
-p, --publish=[]            Publish a container's port(s) to the host
--pid=                      PID namespace to use
--privileged=false          Give extended privileges to this container
--read-only=false           Mount the container's root filesystem as read only
--restart=no                Restart policy to apply when a container exits
--rm=false                  Automatically remove the container when it exits
--security-opt=[]           Security Options
--sig-proxy=true            Proxy received signals to the process
-t, --tty=false             Allocate a pseudo-TTY
-u, --user=                 Username or UID (format: <name|uid>[:<group|gid>])
--ulimit=[]                 Ulimit options
--uts=                      UTS namespace to use
-v, --volume=[]             Bind mount a volume
--volumes-from=[]           Mount volumes from the specified container(s)
-w, --workdir=              Working directory inside the container

 

1.启动创建容器

docker run -it --name **** 镜像名称  /bin/bash (默认采用)

docker run -id --name -p 宿主机端口:容器端口

 

2.查看docker的命令

docker ps 

dockker ps -a

3.删除镜像

docker rmi 容器id #删除单个镜像

docker rmi `docker images -qa`# 删除所有镜像

4.删除docker虚拟机

docker rm -f 容器id  #

docker rm -f $(docker ps -aq) #删除所有容器

5.停止容器

docker stop 容器ID

6.查看docker运行进程信息

docker top Name/ID

7.查看日志:

docker logs -f -t --since="2019-06-31" --tail=10 容器id

docker logs -f -t --since="2018-02-08" --tail=100 CONTAINER_ID  ###显示最后100行

8.进去容器内部

docker attach 容器ID或名字 #退出后容器也会退出

docker exec -it 容器ID或名字 /bin/bash 

9.容器里面被改变的文件或者目录

 docker diff Name/ID

 

posted on 2020-03-19 18:43  BetterManEddy  阅读(84)  评论(0)    收藏  举报