Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by Raunak Jain
80 articles
How to backup and restore a Docker Container?
Docker containers provide a packaged environment for applications, making them portable and lightweight while allowing version control. Sometimes you need to create snapshots or backups of running containers for emergency rollbacks or to preserve specific states. This article covers how to backup and restore Docker containers using built-in commands. Note: The backup methods described here work for containers with embedded data. For containers using separate data volumes, you must create separate backups for each volume. Backing up a Docker Container The backup process involves creating a snapshot of the container's current state and saving it as an ...
Read MoreWorking with Docker Volumes
Docker Volumes are file systems that can be mounted on Docker containers to preserve data independent of the container lifecycle. They allow developers to backup data and share file systems among Docker containers easily. Multiple containers can mount the same volume, enabling seamless data sharing through simple commands and flags. In this article, we will discuss how to create, list, inspect, mount, and delete Docker volumes using command-line operations. Creating a Docker Volume You can create a Docker volume using the create command. Docker creates a directory for the volume on the local machine at /var/lib/docker/volumes/. ...
Read MoreCopying files from Docker container to Host
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 ...
Read MoreImportant instructions used in dockerfile
Dockerfile is a text file containing a series of instructions that define how to build a Docker image. These instructions are executed sequentially when you run the docker build command, creating layers that form the final image. Understanding key Dockerfile instructions is essential for creating efficient, maintainable, and secure container images. In this article, we'll explore the most important Dockerfile instructions that every developer should master to build optimized Docker images. FROM The FROM instruction specifies the base image for your Docker image and must be the first instruction in any Dockerfile (except for ARG instructions that ...
Read MoreFrom inside of a Docker container, how do I connect to the localhost of the machine
When running applications in Docker containers, you often need to connect from the container to services running on the host machine's localhost. For example, if you have an Nginx container that needs to access a MySQL database running on your host's localhost (127.0.0.1), the default container networking won't allow this connection since the container has its own isolated network namespace. This article explains different methods to establish connectivity between Docker containers and host services, with solutions varying by operating system and networking requirements. Method 1 − Host Network Mode (Linux) The simplest solution on Linux is using ...
Read MorePublishing a Docker Image on Dockerhub
Docker Hub is Docker's official cloud-based registry that hosts millions of pre-built Docker images and allows users to publish their own custom images. To interact with Docker Hub for pulling or pushing images, you need to create an account and understand the publishing workflow. Creating a Docker Hub Account and Repository Before publishing images, you must set up your Docker Hub presence − Visit Docker Hub and create an account or sign in with existing credentials. After signing in, click "Create Repository" on the welcome page. Fill in repository details including name, description, and visibility (public ...
Read MoreHow do I get into a Docker container's shell?
Docker containers provide isolated environments for applications, and accessing their shell is essential for debugging, testing, and interactive work. Once you have a Docker container, you can work with its environment just like an Ubuntu machine − execute commands, explore the file system, and deploy applications. There are three primary methods to access a Docker container's shell, depending on the container's current state and your specific needs. Method 1: Docker Run Command Use this method when you want to create and run a new container with immediate shell access. The docker run command creates a container from ...
Read MoreSearching and pulling Docker Images from Dockerhub
The official Docker registry contains a lot of pre-built images and publicly available customized images that are very useful and can be easily pulled by users on their local machine and used as base images for their projects. In fact, you can also build your own customized docker image using one of those publicly available docker images and push it back either in a public or private mode. In this article, we will discuss how to search for a docker image using the search command through the command line interface. We will also see how to filter the search ...
Read MoreHow do I pass environment variables to Docker containers?
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 Flag To ...
Read MoreDocker Image tags and how to use them
Docker Image tags are simple labels or aliases given to a Docker image before or after building to describe that particular image. Tags can represent the version of the project, features of the image, technologies used, or any descriptive identifier. They play a key role in the overall software development lifecycle by helping track different parts of your project and enabling effective version management. While pulling an image, you can specify the tag of the image you want. If not specified, Docker will pull the latest tagged image automatically. Let's explore the common ways tagging is used when working ...
Read More