Found 1383 Articles for Open Source

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

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

4K+ 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

882 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

284 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

257 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

What languages have been used to write Windows, Mac OS and Linux OS?

Mukul Latiyan
Updated on 12-Jul-2022 09:05:15

5K+ Views

We know that an operating system is considered the backbone of any system that you may use. The three most common and widely used operating systems share things in common just as well as they share differences. While there are cases where one might outperform another, those cases and such scenarios are very rare.The most notable difference one can notice is how they store the files in their file structure, like in case of windows, it follows a directory structure to store the different kinds of files of the user, whereas the Mac OS file structure is known as MAC ... Read More

What is the sed in-place flag that works both on Mac and Linux?

Mukul Latiyan
Updated on 31-Jul-2021 12:26:24

3K+ Views

We know that the SED command in Linux stands for stream editor and is mainly used to perform functions on files, and the functions usually are either searching for a word, or replacing it or insertion of something and few more. It is a very useful command and can be found on the Linux kernel.It should also be noted that the BSD (Berkeley Software Distribution) sed shipped with the OS X does need the -i flag to work and the GNU one doesn’t.One way to make the GNU version of the SED to work on the Mac OS X, is ... Read More

Advertisements