Showing posts with label Docker. Show all posts
Showing posts with label Docker. Show all posts

Wednesday, April 1, 2020

Frequently use Docker commands

Frequently use Docker commands 


Docker is well-known and famous containerization platform , in this article i'll be sharing some frequently use docker command and which will help in your work. There are network and volume section which elaborates more with pictorial representation.

Here we go...

Docker Commands 

docker container ls

docker container ls -a

docker container run -d nginx

docker container inspect 182 | less    # to get an IP of running container

docker container pause 182

After pausing you wont be able to access this

docker container unpause 182

To Stop and Kill Container

docker container stop 182


To go inside the container

docker container exec -it ngnixContainer bash

Network in docker

docker network ls

docker network inspect add7666agsg

If you want to create your own network

docker network create -d bridge my-bridge-network

Image network.jpg

docker network inspect ba858ba01ad3

Image network-inspect.jpg



docker container run -d --name nginx3 -p 8081:80  --network my-bridge-network nginx
After this if you run the following command than it shows that newly created container is connected to that defined network

docker network inspect ba858ba01ad3

Image network-linking-container.jpg




Docker Volumes-> docker volume is use to persist data so in case if container goes down or delete than we can save the data
 To create a docker volume use the below command - volume 

docker volume create volume1

docker volume ls

To attach a volume to container and mount point which is created within container

docker container run -d –name nginx4 -v volume1:/volume1 -p 8085:80 nginx

in an above command left side keyword volume1 is host volume which stores on local host or local machine while right side "volume1" is mount point for within container

Refer an image below:  volume.jpg



TO go inside a volume , follow the below path

cd var -> cd lib -> cd docker -> cd volumes -> ls

image volume-list.jpg


To inspect a volume use the following command

docker volume inspect volume1

refer an image showing below: volume-inspect.jpg






If you notice in an image above mount point shows an exact path of volume along with Name.


docker image ls


docker image rm logstash

docker image history logstash

docker image save logstash > logstash.tar

To load image from standard input

docker image load < logstash.tar



Sunday, March 10, 2019

To Run Docker base application on specific IP Address
Image result for docker image
While exploring Docker with .net Core , I confronted various issues later I sorted them one by one.
One of them was after creating images and container it was not hosting on localhost , it troubled me a lot and finally i found a solution for this which I'm sharing through this post.
Step1:
List all the running docker containers
docker container ls
  docker ps -a
  docker inspect -f "{{ .NetworkSettings.Networks.nat.IPAddress }}" 7d13c58d6311

docker ps –a
Step2. After getting list of running container and you should be able to see WebServer with respect to each container running.webserver is nothing just a container ID in simple words.Here depicted below is a list of running container on my workstation:

Kindly use the below command in order to find the specific ip. I’ve used one of the containerId and in order to get IP on which an application might be host.docker inspect -f "{{ .NetworkSettings.Networks.nat.IPAddress }}" 7d13c58d6311
Response: 192.168.172.121
Just open any browser and paste the following URl in that or use the following command to run it in Internet Edge browser
start microsoft-edge:http://192.168.172.121


Some Valuable Commands:

docker build -tag dotnetpiper .
docker image ls
docker run -d -p 8080:8080 dotnetpiper:latest
docker run --name sampleCon -p 8080:8080 dotnetpiper:latest
docker container ls
docker ps -a
docker inspect -f "{{ .NetworkSettings.Networks.nat.IPAddress }}" 4345811895a7
192.168.165.6

  start microsoft-edge:http://192.168.172.121