Featured Post

Working with docker

Docker Image : 

Building a Docker Image  by docker file – includes the build and all the dependencies, 

Container : Running the created docker image as a container on the Docker by using run command. 

Docker Daemon – The background application which manages building, running and distributing docker containers.

Docker Client – The command line tool that helps to interact with docker daemon.

Docker Hub : It is a registry(repository) of Docker Images similar to github repositories of branches and projectes. Hence, once a image is build, it can be pushed to the docker hub and can be pulled and run as a container.

Docker Icon

docker build -t rishoo2019/cheers2019 .

docker run -it --rm rishoo2019/cheers2019

docker pull 

docker images – Displays all the container images present on the docker

docker ps  =  Displays all the containers currently running

docker ps -a  =  Displays all the containers that we ran, also there remanents


docker run -it busybox sh      
Running the run command with the 
-it flags attaches us to an interactivity in the container. 
Now we can run as many commands in the container as we want.


docker rm  = To clean up the remnant containers once done with them and save disk space

$ docker rm $(docker ps -a -q -f status=exited)  Or we can use --- docker container prune

Command for deleting all containers from which we have exited

the -q flag, only returns the numeric IDs and -f filters output based on conditions provided. 
One last thing that'll be useful is the --rm flag that can be passed to docker run 
which automatically deletes the container once it's exited from. 
For one off docker runs, --rm flag is very useful.

 

$ docker run -d -P --name static-site prakhar1989/static-site

$ docker port static-site

In the above command, -d will detach our terminal, 
-P will publish all exposed ports to random ports and 
finally --name corresponds to a name we want to give. 
Now we can see the ports by running the docker port [CONTAINER] command

You can open http://localhost:32769 in your browser.

 

$ docker run -p 8888:80 prakhar1989/static-site

You can also specify a custom port to which 
the client will forward connections to the container.

 

$ docker stop static-site

To stop a detached container

Comments