How to Easily Install Docker

Cara Install Docker dengan Mudah
Bagikan
Table of Contents

In an ever-evolving digital era, the use of container technology—such as Docker—is increasingly becoming the preferred choice for developers and system administrators.

Docker enables users to easily package, ship, and run applications within isolated container environments.

For those looking to understand how to install Docker with ease, this article will cover simple, user-friendly steps.

By following this guide, you can quickly install Docker on your system and leverage the advantages of containers to manage applications efficiently.

Follow these steps to discover the fastest way to begin your journey with Docker.

How to Install Docker on Ubuntu

Cara install docker di Ubuntu

To install Docker on Ubuntu, you can follow these steps. Here is how to install Docker easily:

1. Update Repositories

Ensure your system repositories are up to date by running the following command:

Shell command: sudo apt update

2. Install Dependencies

Install the necessary support packages to ensure a smooth download and installation of Docker:

Code: sudo apt install apt-transport-https ca-certificates curl software-properties-common 

3. Add GPG Key Docker

Add docker official GPG key to the system:

Bash code: curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg –dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg 

4. Add Docker Repository

Add docker repository to software sources list:

Bash code: echo “deb [signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable” | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null 

5. Repository Update (Again)

Perform repository update after adding docker repository:

Sql code: sudo apt update 

6. Install Docker Engine

Finally, install docker engine with the command:

Lua code: sudo apt install docker-ce docker-ce-cli containerd.io 

7. Check Docker Status

Ensure that Docker is installed and running properly:

sudo systemctl status docker

You have now successfully installed Docker on your Ubuntu system. You can proceed to use Docker to manage containers with ease.

How to Install Docker on CentOS

Cara install docker di CentOS

To install Docker on CentOS, you can follow these steps. Here is how to install Docker easily:

1. Update Repositories

Ensure your system repositories are updated by running the following command:

Sql code: sudo yum update 

2. Install Dependencies

Install the supporting packages to ensure you can download and install Docker smoothly:

Kotlin code: sudo yum install -y yum-utils device-mapper-persistent-data lvm2 

3. Add the Docker Repository

Add the Docker repository to your list of software sources using the following command:

Arduino code: sudo yum-config-manager –add-repo https://download.docker.com/linux/centos/docker-ce.repo 

4. Install Docker Engine

Now, install the Docker Engine using the following command:

Lua code: sudo yum install docker-ce docker-ce-cli containerd.io 

5. Start Docker and Set It to Run at Boot

Start Docker and configure it to launch automatically when the system boots up:

Bash code: sudo systemctl start docker sudo systemctl enable docker 

6. Check Docker Status

Verify that Docker is installed and running correctly:

Lua code: sudo systemctl status docker 

7. Add User to the Docker Group (Optional)

To allow a non-root user to run Docker commands without using `sudo`, add the user to the “docker” group:

Copy code: sudo usermod -aG docker your_username

Replace `your_username` with the appropriate username.

Docker is now successfully installed on your CentOS system. You can begin using Docker to manage containers with ease. If you added a user to the “docker” group, remember to log out and log back in—or restart the system—for the changes to take effect.

How to Create a Docker Container

Cara membuat docker container

To create a Docker container, follow these steps:

1. Download an Image

Choose the Docker image you want to use from Docker Hub or another repository. For example, to use an Ubuntu image, run the following command:

Bash code: docker pull ubuntu 

2. Create a Container

Create a container from the downloaded image. Replace <container_name> with your desired name:

Bash code: docker run –name <container_name> -it <image_name> 

Example: docker run –name my-ubuntu-container -it ubuntu 

3. Accessing a Container

If you want to access a running container, use the following command:

Bash code: docker exec -it <container_name> /bin/bash 

Replace <container_name> with the name of the container you have created.

Managing Docker Containers

To manage Docker containers, use the following commands:

1. View the List of Containers

Display a list of containers that are currently running or have been stopped:

Bash code: docker ps -a 

2. Start Container: Run a container that has been stopped:

bashCopy code

docker start <container_name> 

3. Stop Container

Stop running containers:

Bash code: docker stop <container_name> 

4. Delete Container

Delete unneeded containers:

Bash code: docker rm <container_name> 

5. View Log Container

View container activity log:

Bash code: docker logs <container_name> 

6. Sending Commands to a Running Container

Send a command into a running container:

Bash code: docker exec -it <container_name> <command> 

With these steps, you can create, run, and manage Docker containers according to your needs.

Make sure to adjust the container names, images, and commands to suit your specific use case.

Table Of Contents
Recent Article
Disaster Recovery Plan
Disaster Recovery Plan (DRP): Definition, Function, and Types
Block Storage
Block Storage: Definition, Characteristics, and Usage
Object Storage Pengertian, Fungsi, dan Cara Kerja
Object Storage: Definition, Functions, and How It Works
File-Storage
File Storage: Definition, Functions, and How It Works
Akselerasi Transformasi Digital di Indonesia
Accelerating Digital Transformation in Indonesia
8 Faktor Kegagalan Startup Dalam Dunia Bisnis
8 Factors Behind Startup Failures in the Business World
Artikel Terkait