Posts

Docker Commands

Image
 Docker Commands 1. General Docker Commands docker --version Check the installed Docker version. docker info Display system-wide information about Docker. 2. Docker Image Commands docker build -t <image_name> . Build a Docker image from a Dockerfile in the current directory. docker pull <image_name> Download an image from Docker Hub or another registry. docker push <image_name> Push a local image to a Docker registry. docker images or docker image ls List all available images on your local machine. docker rmi <image_name> Remove an image from your local machine. docker tag <source_image> <target_image> Tag an image with a new name. docker inspect <image_name> Get detailed information about an image. 3. Docker Container Commands docker run <image_name> Create and start a container from an image. docker ps or docker container ls List all running containers. docker ps -a or docker contai...

Docker Volumes

Image
When do we need Docker volumes ? What is Docker Volume ? 3 Volume types Docker Volumes in Docker compose file ============ Volumes : On the host there will be a Physical File system path and we plug into the docker container. So what happens is when the container writes it to its file system it get replicated to the physical file system. If i change somerthing on the physical file system gets replicated the containers as well - it works Vice-Versa First type: Host Volume:  This type will give you the right to decide which volume on the host file must be used. docker run -v /home/mount/data:/va/lib/mysql/data /home/mount/data  -- Host directory /va/lib/mysql/data -- Container file system --- Second type  - Anonymous volumes  just by specifying the container filesystem which host file should be mounted is taken care by docker itself so that directory is automatically created by docker  docker run -v  :/va/lib/mysql/data here you are only referencing the conta...

Docker Interview -1

 Difference between docker toolbox and docker desktop   Docker Toolbox and Docker Desktop are both tools used to run Docker on your local machine, but they have some key differences. Docker Toolbox Docker Toolbox is the older version of Docker’s local development environment, and it was designed primarily for systems that did not support Docker Desktop (for example, Windows 7 or older versions). Here’s a quick overview of Docker Toolbox: Components : Docker Engine : The core of Docker, which runs containers. Docker Machine : A tool that helps you create virtual machines on your local system to run Docker containers (for systems that don’t have native support for Docker). Docker Compose : A tool that allows you to define and run multi-container Docker applications. Kitematic : A GUI to interact with Docker containers (though it’s no longer actively maintained). Platform Support : Primarily for Windows and macOS versions prior to Windows 10/11 or macOS High Si...

Multi-Stage Docker file

  A multi-stage Docker build is a feature in Docker that allows you to define multiple build stages in a single Dockerfile. This feature is useful for optimizing the final size of the resulting Docker image and improving the security and maintainability of the build process. With multi-stage builds, you can separate the build environment from the runtime environment, and only include the necessary artifacts in the final image. Here's a brief explanation of how multi-stage Docker builds work: Multiple Stages in a Dockerfile: A multi-stage Dockerfile includes multiple FROM statements, each representing a different build stage. Each stage is essentially a separate Docker image layer with its own set of instructions. Building Artifacts: The first stage is typically used for building the application and generating artifacts. For example, you might use a base image with development tools, dependencies, and libraries to compile code and build the application. Copy Artifacts to a Smaller ...