- vừa được xem lúc

Setup docker lên centos 7 và dùng docker compose tạo hello world với apache

0 0 4

Người đăng: Lập trình đơn giản

Theo Viblo Asia

Link setup của docker:https://docs.docker.com/engine/install/centos/

Phần 1:Setup docker lên centos 7

1.1 Update and Install Dependencies:

sudo yum update -y

1.2 Set up the repository

sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

1.3 Install Docker Engine

sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

1.4 Start Docker.

 sudo systemctl start docker

1.5 Test

sudo docker run hello-world

Thấy kết quả sau là thành công: image.png

Phần 2:Tạo hello world

2.1 Create a directory

Create a new directory for your project.

This will be the root of your Docker Compose application.

cd /home
mkdir hello-apache
cd hello-apache

2.2 Create a file named docker-compose.yaml in the directory

version: "3.8" services: web: image: httpd:latest volumes: - /home/hello-apache/index.html:/usr/local/apache2/htdocs/index.html:ro ports: - "80:80"

2.3 Create file index.html in folder /home/hello-apache with content

Hello, world

2.4 .Build and run the application:

docker compose up -d

2.5 Test

Truy cập browser với url:yourip Ví dụ: http://192.168.64.128 image.png

Một số lệnh cơ bản dùng trong bài viết:

To stop the container and remove its resources, run the following command:

docker compose down

Kiểm tra có các container nào đang chạy:

docker ps -a

Remove container đang chạy

docker rm -f containerid

Bình luận

Bài viết tương tự

- vừa được xem lúc

Cài đặt WSL / WSL2 trên Windows 10 để code như trên Ubuntu

Sau vài ba năm mình chuyển qua code trên Ubuntu thì thật không thể phủ nhận rằng mình đã yêu em nó. Cá nhân mình sử dụng Ubuntu để code web thì thật là tuyệt vời.

0 0 376

- vừa được xem lúc

Phần 1: Giới thiệu về Kubernetes

Kubernetes là gì. Trang chủ: https://kubernetes.io/. Ai cần Kubernetes.

0 0 80

- vừa được xem lúc

Docker: Chưa biết gì đến biết dùng (Phần 1- Lịch sử)

1. Vì sao nên sử dụng. . .

0 0 90

- vừa được xem lúc

Docker - những kiến thức cơ bản phần 1

Giới thiệu. Nếu bạn đang làm ở một công ty công nghệ thông tin, chắc rằng bạn đã được nghe nói về Docker.

0 0 65

- vừa được xem lúc

Docker: Chưa biết gì đến biết dùng (Phần 2 - Dockerfile)

1. Mở đầu.

0 0 54

- vừa được xem lúc

Docker: Chưa biết gì đến biết dùng (Phần 3: Docker-compose)

1. Mở đầu. . .

0 0 106