Hey, You found it !... Didn’t thought you would run into my first post/blog which I would like to share with you. Hope this post satisfies what you been searching for..
Here are the commands which is use a lot. Continuing the post considering u have already installed the docker in your environment.
Table of content 📎
To pull the Docker image available in docker hub repository. Image includes all the open-source images and your custom images.
docker pull naveenv24/hello_world
To search for any image available in docker hub includes additional filter option.
docker search naveenv24/hello_world
All images which are created is dependent on the base image eg. alpine image. If we name the file as Dockerfile by default docker picks up the file to perform actions related to the image
RUN apk add --no-cache mysql-client
docker build . (OR)
docker build dir/pathto/
docker build -f
docker build -f Dockerfile.renamed
This is used to push your new or any updated image to the docker hub. Perquisite is the docker login to the registry.
docker push naveenv24/hello_world
This command will help you remove the image from your environment if it’s not having any dependency. Include
-fto forcefully remove.
docker rmi -f
docker rmi naveenv24/hello_world
This command will create writable container over the specified image. This command will only create the container but will not run/start it.
-Iimplies the image name.
docker create – t -I
docker create – t -I naveenv24/hello_world --name hw-container
This command will create the container if not created and starts the container the
-itimplies interactive mode and
-dimplies detach mode which run the container background
docker run –name
-it -d imageName
docker run –name hw-container -it -d naveenv24/hello_world
This command will rename you’re container name
docker rename hw-container hw-con-new
To update any container related configuration update command is used. Configuration more related to the CPU, memory etc. , Note: currently not available in windows at the time of this been posted.
docker run -dit –name containerName –kernel-memory 50M ubuntu bash
docker update –kernel-memory 100M containerName
Stop the running container or start the non running container or use restart to perform both.
-twait time before killing the container.
docker stop hw-con-new
docker start hw-con-new
docker restart -t
docker restart -t hw-con-new
To suspend any process running in the container temporarily and to un-suspend the process again.
docker pause hw-con-new
docker unpause hw-con-new
To remove the one or more container. To remove the container forcefully add -f or –force.
docker rm -v -f
docker rm -v -f hw-con-new
Listed commands will provide info related to container or process running In the container.
docker ps > will show all the active running container (-a includes remaining available container)
docker logs hw-con-new >> gets logs from container. (You can use a custom log driver, but logs is only available for json-file and journald in 1.10).
docker inspect hw-con-new >> displays all the info related to container includes the ips and ports related details`
docker port hw-con-new>> shows all the ports running in the container`
docker stats hw-con-new >> Display a live stream of container(s) resource usage statistics
To create a network by default will create a bridge network, to specify a network type use -d (driver) option along with the command.
docker network create -d
docker network create -d bridge mynetwork
To view all the available networks in the docker
docker network ls
To view the detailed information about the network
docker network inspect
docker network inspect mynetwork
To remove the network from the available list
docker network rm
docker network rm mynetwork
To connect the container from the network
docker network connect
docker network connect mynetwork hw-con-new
To disconnect the container from the network
docker network disconnect
docker network disconnect mynetwork hw-con-new
These are all the command we will frequently looking into when any implementation is undergone.
Though it might seem few these are basically enough to perform and docker build with multiple services connected through.. 🚀
Appreciate spending your time on this. Hope you liked it.. Share your thoughts this might be useful for improving the quality. 🍻