Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Image RemovedImage Added



Key commands:
Search for container

docker search salt

Documentation:   https://docs.docker.com/engine/reference/commandline/search/

Web site:  https://hub.docker.com/search?q=salt&type=image&operating_system=linux&sort=updated_at&order=desc

Pull an imagedocker pull datica/salt-master
list imagesdocker images

1- create


2- start / run


3- List container


4- Attach to a container


exec ( or re-attach to) a contianer
docker exec -it <container> bash

labuser@saltsackmaster:~/project/ansible/gethw$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
43f11d01c924 juniper/pyez-ansible "ash" 20 hours ago Up 20 hours inspiring_lewin
3a0d030f3f24 juniper/pyez-ansible "ash" 21 hours ago Up 21 hours epic_moser
45b70928ff3e juniper/pyez-ansible "ash" 25 hours ago Up 25 hours funny_kirch

labuser@saltsackmaster:~/project/ansible/gethw$ docker exec -it funny_kirch bash

5- stop:  docker stop

5- docker stop


myplex@batpc2:~/projects/netbox-docker$ docker ps --all
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5a948cd79e71 rancher/rancher:latest "entrypoint.sh" 9 hours ago Up 9 hours 0.0.0.0:443->443/tcp, 0.0.0.0:8080->80/tcp dreamy_diffie

myplex@batpc2:~/projects/netbox-docker$ docker stop dreamy_diffie
dreamy_diffie

myplex@batpc2:~/projects/netbox-docker$ docker rm dreamy_diffie
dreamy_diffie

myplex@batpc2:~/projects/netbox-docker$ docker ps --all
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

myplex@batpc2:~/projects/netbox-docker$

6- remove

6- remove:   docker rm 

[root@centos7 docker-saltstack-junos]# docker ps --all
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c685ea5f042d juniper/saltstack "/entrypoint.sh sa..." 5 days ago Exited (0) 35 minutes ago saltmaster-engine
3a1bcca01ce2 juniper/saltstack "/entrypoint.sh sa..." 5 days ago Exited (0) 5 days ago quizzical_ritchie
05de1c7ea7dc juniper/saltstack "/entrypoint.sh sa..." 5 days ago Exited (0) 5 days ago sad_pasteur
6022ed4930f6 hello-world "/hello" 4 weeks ago Exited (0) 4 weeks ago pensive_hoover

[root@centos7 docker-saltstack-junos]# docker rm saltmaster-engine
saltmaster-engine
docker --help


Code Block
titledocker help
collapsetrue
[root@centos7 docker-saltstack-junos]# docker --help

...



Usage: docker COMMAND

...



A self-sufficient runtime for containers

...



Options:

...


--config string Location of client config files (default "/root/.docker")

...


-D, --debug Enable debug mode

...


--help Print usage

...


-H, --host list Daemon socket(s) to connect to (default [])

...


-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 "/root/.docker/ca.pem")

...


--tlscert string Path to TLS certificate file (default "/root/.docker/cert.pem")

...


--tlskey string Path to TLS key file (default "/root/.docker/key.pem")

...


--tlsverify Use TLS and verify the remote

...


-v, --version Print version information and quit

...



Management Commands:

...


container Manage containers

...


image Manage images

...


network Manage networks

...


node Manage Swarm nodes

...


plugin Manage plugins

...


secret Manage Docker secrets

...


service Manage services

...


stack Manage Docker stacks

...


swarm Manage Swarm

...


system Manage Docker

...


volume Manage volumes

...



Commands:

...


attach Attach 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

...


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

...


inspect Return low-level information on Docker objects

...


kill Kill one or more running containers

...


load Load an image from a tar archive or STDIN

...


login Log in to a Docker registry

...


logout Log out from a Docker registry

...


logs Fetch the logs of a container

...


pause Pause all processes within one or more containers

...


port List port mappings or a specific mapping for the container

...


ps List containers

...


pull Pull an image or a repository from a registry

...


push Push an image or a repository to a registry

...


rename Rename a container

...


restart Restart one or more containers

...


rm Remove one or more containers

...


rmi Remove one or more images

...


run Run a command in a new container

...


save Save one or more images to a tar archive (streamed to STDOUT by default)

...


search Search the Docker Hub for images

...


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

...


tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE

...


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

...


version Show the Docker version information

...


wait Block until one or more containers stop, then print their

...

 exit codesevents

Run 'docker COMMAND --help' for more information on a command.


list Docker networkdocker network ls
details of the of the container

docker inspect <container_ID >

docker container inspect <container_ID >

Code Block
titleinspect
collapsetrue
myplex@batpc2:~$ docker container inspect laughing_greider
[
    {
        "Id": "4fb10dcaf46e519c16bb6de3283ca919e5713ad074219c6271bc0c0abf02225b",
        "Created": "2020-06-01T22:31:37.580432498Z",
        "Path": "run.sh",
        "Args": [
            "--server",
            "https://192.168.0.6:8443",
            "--token",
            "zd2vwnb6zw6mg7wlvxrjjnjs4vmbw4n6vjjxf59dhg8dnz92d76j5j",
            "--ca-checksum",
            "7e4b51c8861d59a3daf382205e407ccf4e5414c860aa6246cf26c63635f71a19",
            "--etcd",
            "--controlplane",
            "--worker"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 14727,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2020-06-15T07:47:14.916896777Z",
            "FinishedAt": "2020-06-15T07:46:48.607553205Z"
        },
        "Image": "sha256:7aab9b2c0cd6d39e03815bf3429be845257a016c3a3f5fd9e22b1ec5c3e9f329",
        "ResolvConfPath": "/var/snap/docker/common/var-lib-docker/containers/4fb10dcaf46e519c16bb6de3283ca919e5713ad074219c6271bc0c0abf02225b/resolv.conf",
        "HostnamePath": "/var/snap/docker/common/var-lib-docker/containers/4fb10dcaf46e519c16bb6de3283ca919e5713ad074219c6271bc0c0abf02225b/hostname",
        "HostsPath": "/var/snap/docker/common/var-lib-docker/containers/4fb10dcaf46e519c16bb6de3283ca919e5713ad074219c6271bc0c0abf02225b/hosts",
        "LogPath": "/var/snap/docker/common/var-lib-docker/containers/4fb10dcaf46e519c16bb6de3283ca919e5713ad074219c6271bc0c0abf02225b/4fb10dcaf46e519c16bb6de3283ca919e5713ad074219c6271bc0c0abf02225b-json.log",
        "Name": "/laughing_greider",
        "RestartCount": 16,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "unconfined",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [
                "/etc/kubernetes:/etc/kubernetes",
                "/var/run:/var/run"
            ],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "host",
            "PortBindings": {},
            "RestartPolicy": {
                "Name": "unless-stopped",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "CapAdd": null,
            "CapDrop": null,
            "Capabilities": null,
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "shareable",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": true,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": [
                "label=disable"
            ],
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": [],
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": [],
            "DeviceCgroupRules": null,
            "DeviceRequests": null,
            "KernelMemory": 0,
            "KernelMemoryTCP": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": false,
            "PidsLimit": 0,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "MaskedPaths": null,
            "ReadonlyPaths": null
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/snap/docker/common/var-lib-docker/overlay2/a84aa9c903e0d233990877cb7086676859b0732333d8c7178e7ce6c13e7be9d2-init/diff:/var/snap/docker/common/var-lib-docker/overlay2/fe04e3dcbf32d2e679db181044b7ce95aaa3f02edae01b7812cd9e492ed5f561/diff:/var/snap/docker/common/var-lib-docker/overlay2/1d68cdfa749e2bdebed74ffc2b57eb07e338b40269e5b0874fb998aac05446ae/diff:/var/snap/docker/common/var-lib-docker/overlay2/2c9b2e2e6cb77fd8466fdaf651308c2392f298cb3c14668a879d8d1b4e49145c/diff:/var/snap/docker/common/var-lib-docker/overlay2/f0cdb19423889bc4d2dee9da7c5e068947be4ebe92f224a3dbbe5acf0c669bce/diff:/var/snap/docker/common/var-lib-docker/overlay2/c2a548927b66a92f3b793746b7b1a1ec01b9173f4ade252ef70edb05fa21e0e9/diff:/var/snap/docker/common/var-lib-docker/overlay2/193eb7bb047332ea3035ff2085e687c924e3ae4ae7df752255b0e08ef16dc2cf/diff:/var/snap/docker/common/var-lib-docker/overlay2/85964f24fd7e400f82370a693c1aab453b25f5918171738651fec65550067879/diff:/var/snap/docker/common/var-lib-docker/overlay2/0858a9b2eecf9738a36a7e7513ec43455c6e20981ce3a2b0c70a60031abc9cce/diff:/var/snap/docker/common/var-lib-docker/overlay2/ff0e609c0e4caf590921e06e7dced0498d0110c2aa8cd63a67b8c27c3aa797f2/diff:/var/snap/docker/common/var-lib-docker/overlay2/ec847a1e7e436c872e0d04de96702a74f35ba54d27ac036a5d04b6aedf9ccf0e/diff",
                "MergedDir": "/var/snap/docker/common/var-lib-docker/overlay2/a84aa9c903e0d233990877cb7086676859b0732333d8c7178e7ce6c13e7be9d2/merged",
                "UpperDir": "/var/snap/docker/common/var-lib-docker/overlay2/a84aa9c903e0d233990877cb7086676859b0732333d8c7178e7ce6c13e7be9d2/diff",
                "WorkDir": "/var/snap/docker/common/var-lib-docker/overlay2/a84aa9c903e0d233990877cb7086676859b0732333d8c7178e7ce6c13e7be9d2/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [
            {
                "Type": "bind",
                "Source": "/etc/kubernetes",
                "Destination": "/etc/kubernetes",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/var/run",
                "Destination": "/var/run",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            }
        ],
        "Config": {
            "Hostname": "batpc2",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "DOCKER_URL_amd64=https://get.docker.com/builds/Linux/x86_64/docker-1.10.3",
                "DOCKER_URL_arm64=https://github.com/rancher/docker/releases/download/v1.10.3-ros1/docker-1.10.3_arm64",
                "DOCKER_URL=DOCKER_URL_amd64",
                "KUBECTL_VERSION=v1.16.8",
                "LOGLEVEL_VERSION=v0.1.3",
                "KUBEPROMPT_VERSION=v1.0.10",
                "DOCKER_API_VERSION=1.24",
                "AGENT_IMAGE=rancher/rancher-agent:v2.4.3",
                "SSL_CERT_DIR=/etc/kubernetes/ssl/certs"
            ],
            "Cmd": [
                "--server",
                "https://192.168.0.6:8443",
                "--token",
                "zd2vwnb6zw6mg7wlvxrjjnjs4vmbw4n6vjjxf59dhg8dnz92d76j5j",
                "--ca-checksum",
                "7e4b51c8861d59a3daf382205e407ccf4e5414c860aa6246cf26c63635f71a19",
                "--etcd",
                "--controlplane",
                "--worker"
            ],
            "Image": "rancher/rancher-agent:v2.4.3",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": [
                "run.sh"
            ],
            "OnBuild": null,
            "Labels": {
                "io.cattle.agent": "true",
                "org.label-schema.build-date": "2020-05-06T22:58:03Z",
                "org.label-schema.schema-version": "1.0",
                "org.label-schema.vcs-ref": "684884c005a6dd9a916861a3e5308815e1eed772",
                "org.label-schema.vcs-url": "https://github.com/rancher/rancher.git"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "4f884591472c9d518b7d98e52d1673f76a77380f4019f0f9e637a2f5dd1e982c",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {},
            "SandboxKey": "/var/snap/docker/471/run/docker/netns/default",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "host": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "e269e39a2ce57d319069e1c0dbe04a94b080c3fd7b352b6dd9fd5783450c2d13",
                    "EndpointID": "e618bea35d108a6f328d8695fe981c202c429f5b5a0a106540b93b9a4a4eddbd",
                    "Gateway": "",
                    "IPAddress": "",
                    "IPPrefixLen": 0,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "",
                    "DriverOpts": null
                }
            }
        }
    }
]
myplex@batpc2:~$


container logs
myplex@batpc2:~$ docker container logs laughing_greider
INFO: Arguments: --server https://192.168.0.6:8443 --token REDACTED --ca-checksum 7e4b51c8861d59a3daf382205e407ccf4e5414c860aa6246cf26c63635f71a19 --etcd --controlplane --worker
INFO: Environment: CATTLE_ADDRESS=192.168.0.6 CATTLE_INTERNAL_ADDRESS= CATTLE_NODE_NAME=batpc2 CATTLE_ROLE=,etcd,worker,controlplane CATTLE_SERVER=https:/ /192.168.0.6:8443 CATTLE_TOKEN=REDACTED
INFO: Using resolv.conf: nameserver 8.8.8.8 search jlkhome.net
ERROR: https://192.168.0.6:8443/ping is not accessible (Empty reply from server)
INFO: Arguments: --server https://192.168.0.6:8443 --token REDACTED --ca-checksum 7e4b51c8861d59a3daf382205e407ccf4e5414c860aa6246cf26c63635f71a19 --etcd --controlplane --worker
INFO: Environment: CATTLE_ADDRESS=192.168.0.6 CATTLE_INTERNAL_ADDRESS= CATTLE_NODE_NAME=batpc2 CATTLE_ROLE=,etcd,worker,controlplane CATTLE_SERVER=https:/ /192.168.0.6:8443 CATTLE_TOKEN=REDACTED
INFO: Using resolv.conf: nameserver 8.8.8.8 search jlkhome.net
INFO: https://192.168.0.6:8443/ping is accessible
INFO: Value from https://192.168.0.6:8443/v3/settings/cacerts is an x509 certificate
time="2020-06-01T22:31:54Z" level=info msg="Rancher agent version v2.4.3 is starting"
time="2020-06-01T22:31:54Z" level=info msg="Option etcd=true"
time="2020-06-01T22:31:54Z" level=info msg="Option controlPlane=true"
time="2020-06-01T22:31:54Z" level=info msg="Option worker=true"
. . .
container stats
myplex@batpc2:~$ docker container stats laughing_greider
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
4fb10dcaf46e laughing_greider 0.12% 17.68MiB / 2.914GiB 0.59% 0B / 0B 72.2MB / 8.19kB 8

display port mapping

docker port healthbot_gateway_1
443/tcp -> 0.0.0.0:8080


display name colunmdocker ps --format '{{.Names}}'
healthbot_gateway_1
healthbot_debugger_1
healthbot_reports_1
healthbot_hbmon_1