Skip to main content

Commands used in Dockefile - Part4

  Docker is an opensource tool used for virtualization and deliver software in the form of packages called Containers. It is one of the most important tools used in networking domain.  Dockerfile  is a template for building the image which contains commands needed to package the software. In this post, I am going to explain the commands ADD & COPY used in  Dockerfile .   ADD Command:   ADD command is used to copy files, directories or files from remote URLS to destination path in the image. The source paths can contain wildcards.   If the destination has relative path, it is relative to the Working directory of the image. Note that source path is always relative to the Docker build context.   ADD command will not support authentication. So, if there are any protected files to be added in  Dockerfile  building, use other tools like curl or  wget   Dockerfile  copying Single & Multiple files, directory using ADD inst...

Networking Commands related to Dockers and Containers

Docker is an open-source software used to develop and deliver the software in the form of packages known as Containers. This post contains the commands needed for debugging or working with docker. This may require some networking basics and understanding of dockers and containers. All the commands are prefixed with sudo to avoid permission denied problem and run the commands like a root user.

Checking Logs of a single container:
sudo docker container logs <Container_Name_Or_ID- This command is used to see whether any errors or exceptions occurred due to the programs or applications running in the container.


Display containers in the system: 
sudo docker container ls  - This command displays the containers running at the current point of time in the system

sudo docker container ls -a  - This commands displays all the containers present in the system which also includes containers in the exited state


Display Images in the system:
sudo docker image ls - This command lists the images that are present in the system at the given point of time. Each image will have ID, size, version if mentioned, and the time at which it was created


Display interfaces of container:
sudo docker exec -it < Container_Name_Or_ID > ifconfig - This command displays interfaces present in the container without logging into the container. The output can be redirected to a file if needed for debugging


Display Interface IP associated with docker network of container:
If we are orchestrating docker containers using Docker, there will be docker-compose.yml listing all networks to be associated with the container. Accordingly, the container will have interfaces. To get the particular network associated interface IP address, use the below command 
sudo docker inspect --format='{{ .NetworkSettings.Networks.<Network_Name>.IPAddress}}' <Container_Name_or_ID>

Displaying and Inspecting docker networks in the system:
sudo docker network ls - This command lists the docker networks present in the system. One can take any network name and inspect it using sudo docker network inspect <network_namewhich returns the output in the format of JSON. By inspecting, one can know ID, scope, type of the driver, containers and their IP’s associated with the network. Also, the subnet, gateway and whether the network supports IPV6 or not can also be known.

Inspecting a container: 
An container can be inspected using sudo docker inspect --format='{{json .Config}} <Container_Name_or_IDwhich returns the output in JSON format. We can know details of exposed ports, the ID of the container, Image associated with the containers and much more details 

Note: The commands starting with sudo may ask the password for the first time. In order to avoid typing password, one can use echo "<Password_of_user_in_System"| sudo –S <Command_to_be_executed_like_root_user>. The -S option allows sudo to read the passwords from standard input

Comments

Popular posts from this blog

Commands used in Dockefile - Part4

  Docker is an opensource tool used for virtualization and deliver software in the form of packages called Containers. It is one of the most important tools used in networking domain.  Dockerfile  is a template for building the image which contains commands needed to package the software. In this post, I am going to explain the commands ADD & COPY used in  Dockerfile .   ADD Command:   ADD command is used to copy files, directories or files from remote URLS to destination path in the image. The source paths can contain wildcards.   If the destination has relative path, it is relative to the Working directory of the image. Note that source path is always relative to the Docker build context.   ADD command will not support authentication. So, if there are any protected files to be added in  Dockerfile  building, use other tools like curl or  wget   Dockerfile  copying Single & Multiple files, directory using ADD inst...

Commands used in Dockerfile - Part3

  Docker is an opensource tool used for virtualization and deliver software in the form of packages called Containers. It is one of the most important tools used in networking domain.  Dockerfile  is a template for building the image which contains commands needed to package the software. In this post, I am going to explain the commands WORKDIR & HEALTHCHECK used in  Dockerfile .   WORKDIR Command:   WORKDIR command is used to set the directory of the image on which the commands like RUN, COPY, ADD, ENTRYPOINT, CMD operates.   The command usage is WORKDIR < Path_To_Dir >. If the directory not exists, it will be created. If the relative path is given to WORKDIR, that path will be relative to the previous WORKDIR command’s path.    In Ubuntu, by default the WORKDIR will be  / . Please find the below sample  Dockerfile  to get clear picture of WORKDIR command:   FROM  ubuntu: 16.04   WORKDIR  /root ...

Vyos - An Open Source Network Operating System

What is  a  Network Operating System?   Networking Operating System (NOS) is an O perating system  that  has the capability to  support workstations, database sharing, application sharing, file ,  and printer access sharing among multiple computers in a network. In general ,  NOS is a specialized operating system used for devices like router, switch or firewall. Features of Networking Operating System:   NOS has the following features: Basic features like protocol support, processor support, hardware detection and multiprocessing support for applications Authentication, access control, authorization ,  and restriction facilities are supported to provide security Provides file service, web service, printing and replication Has Naming and Directory Management services Has  the provision  for user management and remote access & system management Also has internetworking features like routing and ...