I have played with Kubernetes in past, but it has been years and was just to get started. That knowledge still stays inside me to understand discussions related to Kubernetes
Finally decided to get hands deep dirty and created this couple of days back, thought to blog it for reference and might be useful for someone getting started.
Note: after docker login command it will prompt for password, prior have a docker hub account
Push docker image to docker hub account:
$ docker push terminaltolinux/telnet-install
Note: Verify from docker hub account, the docker image will be pushed. Prior create a repo on docker hub
Delete a docker image:
$ docker rmi -f terminaltolinux/telnet-install
Pull docker image from docker hub account:
$ docker run terminaltolinux/telnet-install
Note: it will not find in the local machine as we deleted earlier and will fetch it online and run it, however “docker pull terminaltolinux/telnet-install” can also be used to just pull the image.
Search docker image:
$ docker search mysql
Search docker image with number of stars:
$ docker search -s 1 mysql
Run docker image in background:
$ docker run -d mysql
Run docker image with interactive session:
$ docker run -it ubuntu
List running containers
$ dockers ps
Inspect a container
$ docker inspect <container-id>
Note: container-id will be available from “docker ps”
Logs of standard error or standard out
$ docker log <container-id>
Commit changes to container and save as a separate image. (tag it):
$ docker commit <container-id> nginx-ubuntu
Port binding to container
$ docker run -d -p 6379 reds
Note: -p binds port but if we wanted to map this port directly on the host, we will use the option -p 6379:6379 and if with particular ip then -p 127.0.0.1:6379:6379
Binding directories
$ docker run -d -v “/home/docker/data”:/data reds
Start a container
$ docker start <container-id>
Stop a container
$ docker stop <container-id>
Remove an exited container
$ docker rm <container-id>
Restart a container
$ docker restart <container-id>
Use docker with proxy:
If you want to run docker with environment proxy, edit /etc/default/docker amend your entry for http_proxy
TIP:
If we don’t tell docker explicitly we want to map port, it will block access through that port (because containers are isolated until you tell them you want access)