![]() |
Docker is a platform that provides a set of PaaS ( Platform as a Service ) products that help developers containerize applications, to run them consistently in all supported environments. Docker utilizes virtualization at the OS-level to deliver software in containers. At its core Docker utilizes Docker Engine, an open source component, to build, run and manage Docker Containers. Docker engine consists of two main components:
What is a Docker Container?A container is a self-contained run time instance of an image. It is a virtual environment that consists of the application and all of it’s dependencies. Containerization enables developers to package software and it’s dependencies into one unit and safely deploy them in all supported environments like Kubernetes, AWS EC2 instances, Virtual machines etc. What is a Docker Image?A Docker image is a read-only template that contains the instructions and all the necessary components to create a self-contained application instance (Docker container). Docker Hub and Private RegistriesDocker Hub and private registries serve as repositories for storing and managing Docker images. Docker Hub is a public registry offered by Docker itself. Whereas, Private registries are secure, on-premise or cloud-based repositories specifically designed for storing and managing an organization’s private Docker images. For pulling private images or pushing your own images to Docker Hub or to access an image from a Private registry, a developer must authenticate himself. This can be achieved using the Docker CLI. Setting up your Docker EnvironmentPrerequisites
InstallationWindows and macOS:
Ubuntu: For Ubuntu based distributions you can use the following commands. #Check Docker's official documentation for further info For other distributions please refer to the official docker documentation. Configuration1. Verify Installation:To verify docker’s installation open a terminal and run `docker –version` docker --version
![]() docker version 2. Start Docker
![]() Docker Engine Start/Stop Logging into Docker HubTo interact with Docker Hub, you first need to create an account and log in via the command line. Creating a Docker Hub Account
Logging in via Command LineStep 1: Open a terminal Step 2: use the `docker login` command docker login
Step 3: Enter your username and password when prompted username:<enter your username> ![]() Step 4: On Successful login you will be prompted with: `login succeeded` login succeeded
Pulling and Pushing Docker Images From Docker HubPulling Images from Docker Hubdocker search <image_name>
2. Pull the image using `docker pull` docker pull <image_name>
Example: ![]() docker search ![]() docker pull Building And Pushing Your Own Docker Images1. Create a dockerfile:A `dockerfile` contains instructions for building a Docker image. Example: FROM ubuntu:latest 2. Build the image:build the docker image using the following command: docker build -t <your_image_name> .
![]() docker build 3. Tag the image for a specific repository:docker tag <your_image_name> <your_dockerhub_username>/<repository_name>:<tag>
![]() docker tag 4. Push the image to docker hub using the following command:You can use docker push to push your image to docker hub as follows docker push <your_dockerhub_username>/<repository_name>:<tag>
![]() docker push Upon successful execution you’ll find your image uploaded to docker hub. ![]() docker hub Docker for Pulling and Pushing Images – FAQsWhat is a Docker file?
What’s the difference between Docker and Docker Compose?
How to learn to use docker?
|
Reffered: https://www.geeksforgeeks.org
DevOps |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 14 |