This blog will capture and document common Docker commands. I'll try to keep them in a logical flow so you don't have to jump around. This is for me as much as it is for you.
If you have suggestions for other commands, please leave in comments. Also, if I am wrong about something, please point it out and I will correct it. If you have a lot of really good info, I may even give you edit rights.
Commands
How to get an image locally?
docker pull {dockerimage} - pulls a docker image down to your local docker registry.
How to add an insecure registry to docker?
vi /etc/sysconfig/docker - opens docker configuration for editing (may need sudo).
Add your registry:
# If you have a registry secured with https but do not have proper certs
# distributed, you can tell docker to not look for full authorization by
# adding the registry to the INSECURE_REGISTRY line and uncommenting it.
INSECURE_REGISTRY='--insecure-registry docker-registry.usersys.mycompany.com --insecure-registry ce-registry.usersys.mycompany.com --insecure-registry localhost:5000 --insecure-registry 172.30.0.0/16'
How to run an image?
docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]
There are a lot of options available, here is an example I use most often.
docker run -it -p 8080:8080 -p 8443:8443 -p 9990:9990 -p 31000:31000 {docker_image}
How to get ips for Docker images?
There are a few ways to go about this, but this seems the easiest easiest assuming your docker is using a network bridge (the default):
docker network inspect bridge
will output something like this:
[
{
"Name": "bridge",
"Id": "101764200e68e573306bf799e0b7ed04ca03db8a4bb4c5f9a98bbf8f8a6de8dc",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.17.0.0/16",
"Gateway": "172.17.0.1"
}
]
},
"Internal": false,
"Containers": {
"280062f9a863983516ebe80b9aba9e507351cb0c85bb7b5d53dfc0473df8247b": {
"Name": "naughty_liskov",
"EndpointID": "91b6c2b270d72b2e48255d66580aaecfd3029dd7dc7fab4e52b369f412e9c634",
"MacAddress": "02:42:ac:11:00:02",
"IPv4Address": "172.17.0.2/16",
"IPv6Address": ""
}
},
"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": {}
}
]
More to come...
Comments