Found 2065 Articles for Operating System

How is Docker different from a Virtual Machine?

Raunak Jain
Updated on 06-Aug-2021 11:44:52

204 Views

When we speak about efficient utilization and proper allocation of computer resources, both virtual machines, and Docker containers are effective in their own ways. In the past few years, Docker containers have gained tremendous popularity among organizations of all sizes. It is very important to understand the use-cases and purposes that they both serve if you want to decide which of the two is better for your requirements. In this article, let’s discuss the basic differences between Docker containers and virtual machines.However, before we start the discussion make sure that you have the basic knowledge of what Docker is. You ... Read More

How does one remove a Docker image?

Raunak Jain
Updated on 06-Aug-2021 11:39:49

2K+ Views

If you have been using Docker for quite a long time now, you might have several unused images already existing in your local machine. These images might be previously downloaded older versions, or simply an image that you downloaded for testing. These images take up a lot of space unnecessarily and reduce the overall performance and experience. Moreover, they are several unused, dangling images as well.It’s always better to remove these older images which will help you to keep track of all your useful images in a better way. Docker allows you to remove images quite easily and through many ... Read More

How do I run a command on an already existing Docker container?

Raunak Jain
Updated on 06-Aug-2021 11:36:00

3K+ Views

Suppose you have already created a Docker container previously and have worked with it. Now, you have stopped the container. So, the container is in exited state. What if you want to run a command inside the container?Typically, there can be two cases. Either the container is stopped using the Docker stop command or the container is currently running in the background. In such a case, either you can start the container back, access it’s bash, and execute whatever command that you want. This is perfect for containers that are not running. Another solution is that you use the Docker ... Read More

How do I pass environment variables to Docker containers?

Raunak Jain
Updated on 06-Aug-2021 11:34:16

1K+ Views

Suppose you are using a MySQL Docker container and you want to pass environment variables to your container while running the container. It’s always a good idea to isolate the services from the configuration and it’s always advised to use environment variables for this purpose.Predominantly, there are three different ways through which we can pass environment variables to our Docker containers. These are by using the -e, --env-file, and the ENV instruction inside the Dockerfile. Let’s check out all these methods one by one with examples.Passing environment variables using the --env or -e flagTo demonstrate this example, let’s use the ... Read More

How do I get into a Docker container's shell?

Raunak Jain
Updated on 06-Aug-2021 11:32:03

15K+ Views

Once you have your Docker container up and running, you can work with the environment of the Docker container in the same way you would do with an Ubuntu machine. You can access the bash or shell of the container and execute commands inside it and play around with the file system. You can build, test, and deploy your applications inside the container itself.Predominantly, there are 3 ways to access the shell of a running container. These are -Using the Docker run command to run a container and access its shell.Using the Docker exec command to run commands in an ... Read More

From inside of a Docker container, how do I connect to the localhost of the machine

Raunak Jain
Updated on 06-Aug-2021 11:28:12

13K+ Views

Suppose you have an Nginx web server running inside an Nginx container in your host machine. And you have a MySQL database running in your host machine. Now, you want to access the MySQL server in your host machine from the Nginx container. Also, the MySQL is running on your localhost and the host machine does not expose any port to the outside world. Hence, we can conclude that MySQL is bound to be run on localhost only and not accessible to the outside world because it is not bound on the IP address.In this article, we will explain the ... Read More

Copying files from Docker container to Host

Raunak Jain
Updated on 06-Aug-2021 11:26:49

2K+ Views

We can use the Docker build command to build Docker images using a build context. The build context contains all the files which are required to create your containerized application environment. This includes the Dockerfile to build the Docker images, source code of the application, Dockerignore files, all the files, and directories that you want to be there beforehand in the container when you run it.However, it often happens that you might want to copy some files from the container to the host machine. For example, if you are working on an application inside a Docker container and you have ... Read More

Where can I set environment variables that crontab will use?

Mukul Latiyan
Updated on 31-Jul-2021 12:29:08

844 Views

In normal cases we make use of the bash_profile or bashrc in case of Ubuntu and zshrc in case of Mac OS, to set our environment variables and then those variables are made available to us everywhere on the terminal we want.Let’s consider a simple example where we have some environment variable in bash_profile and we are making use of it in the terminal.Consider the bash_profile output shown below −immukul@192 dir1 % cat ~/.bash_profile export JAVA_HOME=$(/usr/libexec/java_home) export PATH=$PATH:/usr/local/node/bin export GOROOT=/usr/local/go export GOPATH=/Users/immukul/go_projectsAs we can see there are many variables present in the bash_profile file, we can use these variables in ... Read More

What's the difference between nohup and ampersand (&) on Linux?

Mukul Latiyan
Updated on 31-Jul-2021 12:30:16

237 Views

Linux provides us with different utility commands that we can make use of to print a random line from any files in the Unix command line. Mostly we make use of either the shuf command or the sort command, and in this article I’ll explain both the commands and which one is better and why.Shuf CommandThe shuf command in Linux is used to write random permutations of the input lines to the standard output. The idea of randomizing the input is the same as one does when the cards are shuffled. On most of the Linux operating systems it is ... Read More

What Linux utility for sorting processes by network usage?

Mukul Latiyan
Updated on 31-Jul-2021 12:32:37

235 Views

Linux provides the famous top command utility that provides us with all the information about the processes, their time, their respective IDs, how much CPU chunk they are consuming and much more. The only issue with that is the processes are not sorted in any order and the order changes frequently.There are certain cases where we would like the output to be in a sorted manner somehow, like sorted in the sense that the process which is using the most network will be at the top.One such command line program that we can use that will provide us the desired ... Read More

Advertisements