Learning coding means GreatToCode Be more than a Coder ! Greattocode , Join GreatToCode Community,1000+ Students Trusted On Us .If You want to learn coding, Then GreatToCode Help You.No matter what It Takes !


CODE YOUR WAY TO A MORE FULFILLING And HIGHER PAYING CAREER IN TECH, START CODING FOR FREE Camp With GreatToCode - Join the Thousands learning to code with GreatToCode
Interactive online coding classes for at-home learning with GreatToCode . Try ₹Free Per Month Coding Classes With The Top Teachers . Docker Tutorial: Freshers and Experienced

Docker Tutorial: Freshers and Experienced

Docker is an excellent platform for designing, deploying, and executing programs that rely on containers. Docker allows you to construct a container that contains your program, well any packages or libraries that it relies on, as well as any configuration information. When you managed to make a webpage, you used to have to buy a server, install Linux, build up a LAMP architecture, and then run the program. If your program became famous, you used effective load balancing by adding an extra server to guarantee that it didn't crash due to excessive traffic.

The best thing about open source is whether you get to choose the tech you want to employ to finish a job. Docker engine is suitable for single engineers that want a lightweight, pure environment to run but do not require extensive management.

Docker Community Edition (docker-ce) is a wonderful method to begin with containers if Docker is installed on your system and everyone around you is comfortable with the Docker ecosystem. Because the fight to ensure open standards prevails is continuous, sticking with projects that love and appreciate open source should be a long-term plan for your container solution. Private extras may appear interesting at first, but once you lock your tools to a solution that does not allow for the transfer, you lack your freedom of choice. Containers may be freed if they're used correctly.

In this cheat sheet, we will highlight all the important docker commands that caters to freshers and experienced professionals, so let's move forward.

Docker Tutorial: Freshers and Experienced

1. Installation of Docker

CommandMeaningSyntax
For WindowsThis command helps you to install Docker on windows.https://download.docker.com/win/stable/InstallDocker.msi
For LinuxThis command helps you to install Docker on Linux.curl -sSL https://get.docker.com/ | sh
For macThis command helps you to install Docker on mac os.https://download.docker.com/mac/stable/Docker.dmg

2. Docker Registry and Repository

CommandMeaningSyntax
Login to a RegistryThis command helps you log in to your Registry.
docker login
docker login localhost:8080
Logout from a registry:This command helps you log out from your Registry.
docker logout
docker logout localhost:8080
Searching an imageBy using this docker command you can search any image from your docker.
search nginx
docker search --filter stars=3 --no-trunc nginx
Pulling an ImageThis command can be used to download a specific image or set of images.
docker image pull nginx
docker image pull eon01/nginx localhost:5000/myadmin/nginx
Pushing an imageThis command can be used to push a specific image or set of images.
docker image push eon01/nginx
docker image push eon01/nginx localhost:5000/myadmin/nginx

3. Running Containers

CommandMeaningSyntax
Command to create a containerThis command is used to create a container without running
docker container create -t -i eon01/infinite --name XYZ
Command to run a containerThis command is used to run a container
docker container run -it --name XYZ -d eon01/infinite
Command to rename a containerUse this command to rename a container
docker container rename XYZ infinity
Command for removing a containerThis command is used to remove container in the topic
docker container rm infinite
Update a containerThis command is used to update container in the topic
docker container update --cpu-shares 512 -m 300M infinite



4. Commands for Starting or Stopping the Container

CommandMeaningSyntax
Command for starting a containerThis command is used for starting a container 
docker container start nginx
Command for stopping a containerThis command is used for stopping a container
docker container stop nginx
Command for restarting the containerThis command is used for restarting a container
docker container restart nginx
Command for pausing the containerThis command is used for pausing a container
docker container pause nginx
Command for unpausing the containerThis command is used for unpausing a container in the docker 
docker container unpause nginx
Command for Blocking a containerThis command is used for blocking a container in the docker 
docker container wait nginx
Sending a SIGKILLThis command is used for Sending a SIGKILL in the docker 
docker container kill nginx
Command for sending another signalThis command is used for for sending another signal
docker container kill -s HUP nginx
Command for Connecting to an Existing ContainerWe can use this command for Command for Connecting to an Existing Container
docker container attach nginx

5. Commands for Obtaining Container Information

CommandMeaningSyntax
Fetching information From Running ContainersWe can fetch  information from running container by using this command
docker ps

Or 

docker container ls
Command for fetching about every containerThis command for fetching about every container
docker container ls -a

Or

docker ps -a
Command for container logWe can use this command to see the container log
docker logs infinite
Command for ‘tail -f’ Containers’ LogsWith this command Container isn't running in the foreground, and if there isn't anything running in the foreground, Docker closes automatically.
docker container logs infinite -f

Command for Inspecting Containers


 

This is the command use for inspecting containers
docker container inspect infinite

docker container inspect --format '' $(docker ps -q)
Command for Containers EventsTo obtain real-time events from the server, use docker events.
docker system events infinite
Command for Public PortsUse this command for finding a public port
docker container port infinite
Command for Running ProcessesWe can use this commands for displaying the running processes in the container
docker container top infinite
Command for Container Resource UsageIt displays a live stream of resources usage statics  for containers
docker container stats infinite
Commands for Inspecting changes to files or directories on a container’s filesystemThis command is used for inspecting changes to files or directories on a container’s filesystem 
docker container diff infinite

6. Commands for Managing Images

CommandMeaning Syntax 
Commands for listing imagesThis command is used to listing images 
docker image ls
Command for Building images From the current directory's DockerfileThis command is used for building from the current directory’s dockerfile 
docker build 
Command for Building images From a GIT remote repositoryThis command is used Building images command Using a remote GIT repository
docker build github.com/creack/docker-firefox
Commands for tagging and buildingThis command for tagging and building.
docker build -t eon/infinite 
Specifying the Build Context while creating a DockerfileThis is use to Build an image from a Dockerfile
docker build -f myDockerfile
Creating a Dockerfile from a URLIt wil help to create a dockerfile with a specific URL. 
curl example.com/remote/Dockerfile | docker build -f - 
Command for removing imageThis command is used to removing a7n image 
docker image rm nginx
Using a File or the Normal Input Stream to Load a Tarred RepositoryUse STDIN or a tar archive to load an image.
docker image load < ubuntu.tar.gz

docker build -f myOtherDockerfile 
Image Saving to a Tar Archiveard Input StreamIt is used Save one or more images to a tar archive
docker image save busybox > ubuntu.tar
Showing the History of an ImageThis command will let know the history of the image inside the docker
image history
Making an Image Out of a ContainerThis command will help you to take an image out of the container
docker container commit nginx
Command for image taggingWe can use this command for image tagging
docker image tag nginx eon01/nginx
Command for pushing an imageWe can push any image through this command
docker image push eon01/nginx

7. Commands for Networking

CommandMeaningSyntax 
Command for overlay networkThis is used to establish a distributed network between many Docker daemon hosts.
docker network create -d overlay MyOverlayNetwork
Command for Bridge networkTo establish container test1 to bridge demo-bridge, type docker network connect demo-bridge test1.
docker network create -d bridge MyBridgeNetwork
Command for removing a networkThis command s used to remove an overlay network 
docker network rm MyOverlayNetwork
Command for network listingThis command is used to listing the overlay networks
docker network ls
Command for Getting Information About a NetworkWe can get information about an overlay network with the help of this command
docker network inspect MyOverlayNetwork
Command for Connecting a Running Container to a NetworkBy using this command we can connect a container to network
docker network connect MyOverlayNetwork nginx
Command for Connecting a Container to a Network When it StartsWhen the container starts we can use this command to connect a container to network
docker container run -it -d --network=MyOverlayNetwork nginx
Command for Disconnecting a Container from a NetworkWe can use this Command for disconnecting a container from network
docker network disconnect MyOverlayNetwork nginx
Command for Exposing PortsWe can expose the empty ports using this command
EXPOSE <port_number>

8. Commands for Cleaning Docker

Command Meaning Syntax 
Command for Removing a Running ContainerWe can remove a running container by using this command
docker container rm nginx
Command for Removing a Container and its VolumeWe  can use this command for removing the container and the things inside it
docker container rm -v nginx
Command for Removing all Exited ContainersWe can use this command for removing all the exited containers
docker container rm $(docker container ls -a -f status=exited -q)
Command for Removing All Stopped ContainersWe can remove all the stopped containers by using this command
docker container rm `docker container ls -a -q`
Command for Removing a Docker ImageThis command is used fr removing a docker image 
docker image rm nginx
Command for Dangling ImagesWe can dangle the images with this command
docker image rm $(docker image ls -f dangling=true -q)
Command for Removing all ImagesWe can remove all the image in the docker by using this commands
docker image rm $(docker image ls -a -q)
Commands for Delete all Untagged ImagesWe can delete all the untagged images with the use of this command
docker image rm -f $(docker image ls | grep "^<none>" | awk "{print $3}")
Command for Stopping & Removing all ContainersFor stopping and removing all the container we can use this command
docker container stop $(docker container ls -a -q) && docker container rm $(docker container ls -a -q)
Command for Removing Dangling VolumesWe can remove all the dangling volumes by using this command
docker volume rm $(docker volume ls -f dangling=true -q)
Command for removing all unneeded (containers, images, networks and volumes)This command is use to remove the unnecessary thing 
docker system prune -f
Command for Clean allWe cam use this command for cleaning everything in the docker
docker system prune -a

Conclusion

You should have a solid knowledge of what Docker is and how it operates by this point. Docker's finest feature is cooperation. Docker images may be uploaded to a repo and then downloaded to any other server to execute containers. Furthermore, the Docker hub has hundreds of images developed by users, which you may download down to your servers depending on your specific application. It is also often used throughout container orchestration technologies such as Kubernetes.

Docker is one of the greatest production technologies available today, and its demand is expanding rapidly. It is considered ideal for larger businesses, and because it is open-source, it is a versatile platform that can be used to construct a wide range of applications.

References and Resources

2.

What is a decent docker exec analogy?

3.

When you load Docker runtime on a Docker host, which one of the following network interfaces is created?

4.

Which of the below best describes the connection between a Docker image and a Docker container?
 

5.

Which Docker CLI commands should be used in what order to produce a Docker image?

6.

Which command provides access to the live output of processes operating within a container?

7.

What does the CMD instruction do if the ENTRYPOINT command is also used?

8.

Which Docker component interacts with the kernel primitives needed to generate containers?



Post a Comment

0 Comments

•Give The opportunity to your child with GreatToCode Kid's • Online Coding Classes for Your Kid • Introduce Your kid To the world's of coding
•Fuel You Career with our 100+ Hiring Partners, Advance Your Career in Tech with GreatToCode. •Join The Largest Tech and coding Community and Fast Forward Your career with GreatToCode. •10000+ Learner's+ 90 % placement Guarantee. • Learning Coding is Better with the GreatToCode community .
•Greattocode Kid's •GreatToCode Career •GreatToCode Interview •GreatToCode Professional •GreatToCode for schools •GreatToCode For colleges •GreatToCods For Businesses.
Are you ready to join the millions of people learning to code? GreatToCode Pass is your one-stop-shop to get access to 1000+ courses, top-notch support, and successful job placement. What are you waiting for? Sign up now and get your future in motion with GreatToCode Pass.