Here we have compiled the most probable DevOps interview questions asked in the industry. You will learn about software version control, Git repository, reverting a commit in Git, Vagrant, continuous testing elements, and the importance of continuous integration, testing, and deployment. These questions are curated after discussing with many interviewers and DevOps Training experts.
A complete lifecycle of Docker containers:
*. Create a container
*. Run the container
*. Start the container
*. Stop the container
*. Pause the container
*. Unpause the container
*. Restart the container
*. Kill the container
*. Destroy the container
You can use Docker Machine to install Docker Engine, and Docker Swarm on one or more virtual systems. These hosts can be managed by using the docker-machine commands.
This is the command used to know about Docker Client and Server versions:
$ sudo docker --version
You can use the following command to get detailed information about the docker installed on your system.
$ docker info (or)
$ docker ps -a (or)
$ docker container ls -a
You can get the number of containers running, paused, stopped, the number of images and a lot more.
Once you’ve written a Dockerfile, you need to build it to create an image with those specifications. Use the following command to build a Dockerfile:
$ "docker build -t < username/imageName > ."
Here at the end of the above command one space and period(.) includes a command to locate the path of Dockerfile. And instead of period(.) use the entire path if it is not stored in the same directory.
You can use the following command to login into hub.docker.com:
$ docker login
You’ll be prompted for your username and password, insert those, you’re logged in.
Pull an image from docker hub to your local system with one simple command:
$ docker pull < image_name >
Then write a docker file as per your requirement, Then build the image using that Dockerfile
$ " docker build -t < username/image-name:tag > . ". Now you have your own customised image.
This is the command to lists down all the running containers:
$ docker ps (or)
$ docker container ls
This is the command to get access to a running container and to run a commands in it:
$ docker exec -it < container-id > bash-name
For example $ docker exec -it my_container /bin/bash
The exec command lets you execute commands inside a container.
$ docker attach < container-id >
But, the first method is preferable and recommended.
To start a docker container this is the command :
$ docker start < container_id >and for stopping a running container:
$ docker stop < container_id >
And to kill a container:
$ docker kill < container_id >