Cách cài đặt Docker trên Ubuntu 20.04 LTS

3 năm trước, Docker, Ubuntu, 905 Lượt xem

Bài viết này netweb sẽ hướng dẫn các bạn cài đặt docker trên ubuntu nhé!

Đầu tiên các bạn gõ lệnh Docker vào command nhé

docker

Sau đó hệ thống sẽ báo bạn là có 2 cách cài đặt như hình dưới

snap install docker     # version 19.03.13, or
apt  install docker.io  # version 20.10.2-0ubuntu1~20.04.2

Sau khi gõ lệnh các bạn chờ vài phút để docker tiến hành cài đặt vào máy tính của các bạn nhé!

Sau khi cài đặt xong các bạn gõ lệnh docker --version

docker --version

Hiển thị output như dưới thì đã cài đặt xong docker

Docker version 20.10.2, build 20.10.2-0ubuntu1~20.04.2

Kiểm tra trạng thái docker đã active trên máy của các bạn hay chưa

sudo systemctl status docker
docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2021-05-11 10:32:25 CEST; 4min 6s ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 93938 (dockerd)
      Tasks: 8
     Memory: 49.5M
     CGroup: /system.slice/docker.service
             └─93938 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Nếu docker chưa được active thì các bạn dùng lệnh này active docker lên nhé!

sudo systemctl enable --now docker

Chạy chương trình docker hello-world đầu tiên

sudo docker run hello-world

hiện thông báo như thế này thì đã thành công

latest: Pulling from library/hello-world
b8dfde127a29: Pull complete
Digest: sha256:f2266cbfc127c960fd30e76b7c792dc23b588c0db76233517e1891a4e357d519
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Hiển thị các images docker đã tải về từ docker hub

sudo docker images
REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
hello-world   latest    d1165f221234   2 months ago   13.3kB

Chúc các bạn thành công!

Bài viết mới cập nhập

  • Hướng dẫn Plugin floating contact

    Hướng dẫn Plugin floating contact

    10 tháng trước, 338 Lượt xem

    Netweb xin hướng dẫn cách quản lý Plugin floating contact các bạn nhớ làm theo kỹ tường bước để plugin hoạt động Tính năng: Hiển…

  • Backup Yandex Mail

    Backup Yandex Mail

    12 tháng trước, 229 Lượt xem

    Khác với dịch vụ email theo tên của microsoft và google với chi phí đắt đỏ tầm 1tr/năm/1user, vì thế nên netweb khuyên dùng dịch…

Bình luận trên facebook netweb.vn

Đam mê thiết kế web, kinh nghiệm 9 năm trong nghề thiết kế website, đang thiết kế web dạo tại netweb.vn, Callme: 08.9898.2526 (Mr Hải)