栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

docker命令

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

docker命令

docker 网络管理
    docker network create 
      --driver=bridge 
      --subnet=172.28.0.0/16 
      --ip-range=172.28.5.0/24 
      --gateway=172.28.5.254 
      br0     -o com.docker.network.bridge.name=br0
    

    修改ip addr网卡名称

    docker network list
    查看系统默认docker0(20d5d1508381)的底层信息

    [root@docker2 ~]# docker netwrok inspect 20d5d1508381

    ​ }
    ​ },
    ​ “Options”: {
    ​ “com.docker.network.bridge.default_bridge”: “true”,
    ​ “com.docker.network.bridge.enable_icc”: “true”,
    ​ “com.docker.network.bridge.enable_ip_masquerade”: “true”,
    ​ “com.docker.network.bridge.host_binding_ipv4”: “0.0.0.0”,
    ​ “com.docker.network.bridge.name": "docker0”, #注意这个命令行
    ​ “com.docker.network.driver.mtu”: “1500”
    ​ },
    ​ “Labels”: {}
    }
    ]

     docker network inspect [OPTIONS] NETWORK [NETWORK...]
    
     docker network prune [OPTIONS]
     Remove all unused networks. Unused networks are those which are not referenced by any containers.
    
     docker network rm 3695c422697f|my-network
    
docker命令

    docker search

    docker pull

    docker commit

    docker commit [OPTIONS] ConTAINER [REPOSITORY[:TAG]]
    Create a new image from a container’s changes
    

    docker export

    docker export [OPTIONS] ConTAINER
    Export a container’s filesystem as a tar archive
    

    docker import

    docker import [OPTIONS] file|URL|- [REPOSITORY[:TAG]]
    import the contents from a tarball to create a filesystem image
    docker import https://example.com/exampleimage.tgz
    

    docker load

     docker load [OPTIONS]
    docker image ls
     docker load < busybox.tar.gz
     docker images
     docker load --input fedora.tar
     docker images
    

    docker save

     docker save busybox > busybox.tar
     ls -sh busybox.tar
     docker save --output busybox.tar busybox
    

    docker info

    docker inspect

    Get an instance’s IP address

    For the most part, you can pick out any field from the JSON in a fairly straightforward manner.

     docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $INSTANCE_ID
    
    Get an instance’s MAC address
     docker inspect --format='{{range .NetworkSettings.Networks}}{{.MacAddress}}{{end}}' $INSTANCE_ID
    
    Get an instance’s log path
     docker inspect --format='{{.LogPath}}' $INSTANCE_ID
    
    Get an instance’s image name
     docker inspect --format='{{.Config.Image}}' $INSTANCE_ID
    
    List all port bindings

    You can loop over arrays and maps in the results to produce simple text output:

     docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' $INSTANCE_ID
    
    Find a specific port mapping

    The .Field syntax doesn’t work when the field name begins with a number, but the template language’s index function does. The .NetworkSettings.Ports section contains a map of the internal port mappings to a list of external address/port objects. To grab just the numeric public port, you use index to find the specific port map, and then index 0 contains the first object inside of that. Then we ask for the HostPort field to get the public address.

     docker inspect --format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0).HostPort}}' $INSTANCE_ID
    
    Get a subsection in JSON format

    If you request a field which is itself a structure containing other fields, by default you get a Go-style dump of the inner values. Docker adds a template function, json, which can be applied to get results in JSON format.

     docker inspect --format='{{json .Config}}' $INSTANCE_ID
    
    docker kill my_container
    Send a KILL signal to a container
    

    docker rename

    docker rename ConTAINER NEW_NAME
    

    docker restart

     docker restart [OPTIONS] ConTAINER [CONTAINER...]
    

    docker rm

    docker rm [OPTIONS] ConTAINER [CONTAINER...]
    

    docker rmi

    docker rmi [OPTIONS] IMAGE [IMAGE...]
    

    docker run

    docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
    docker run --name test -it debian
    docker run -t -i --rm ubuntu bash
    docker run -t -i --privileged ubuntu bash
    docker  run -w /path/to/dir/ -i -t  ubuntu pwd
    docker run -v /doesnt/exist:/foo -w /foo -i -t ubuntu bash
    docker run --read-only -v /icanwrite busybox touch /icanwrite/here
    docker run -t -i -v /var/run/docker.sock:/var/run/docker.sock -v /path/to/static-docker-binary:/usr/bin/docker busybox sh
    docker run -t -i --mount type=bind,src=/data,dst=/data busybox sh
    docker run --read-only --mount type=volume,target=/icanwrite busybox touch /icanwrite/here
    docker run -p 127.0.0.1:80:8080/tcp ubuntu bash
    docker run -e MYVAR1 --env MYVAR2=foo --env-file ./env.list ubuntu bash
    docker run -itd --network=my-net --ip=10.10.9.75 busybox
    docker run --restart=always redis
           noon-failure[:max-retries]unless-stopped always
    docker run --sysctl net.ipv4.ip_forward=1 someimage
    docker start [OPTIONS] ConTAINER [CONTAINER...]
    docker stop [OPTIONS] ConTAINER [CONTAINER...]
    
docker image 命令
    docker image lsrmpull
docker container命令
    docker container ls -astoprmstartrestart
容器配置文件
    /var/lib/docker/containers

注意:先关闭docker,再修改配置文件
systemctl stop docker

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/741784.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号