lan1note

[Docker] Cài đặt – Run Hello World

Bài viết chia sẻ cách cài đặt Docker và chạy container hello-world


1| Cài đặt Docker

◆ Môi trường:

  • OS: Centos 7.6

◆ Cài đặt

#! /bin/sh

# Install "Docker"
yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2

yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

yum install -y \
  docker-ce-19.03.1 \
  docker-ce-cli-19.03.1 \
  containerd.io

systemctl enable docker
systemctl start docker

◆ Kiểm tra version

$ docker -v
Docker version 19.03.1, build 74b1e89

2| Tạo container Hello world

$ docker run hello-world

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete 
Digest: sha256:4fe721ccc2e8dc7362278a29dc660d833570ec2682f4e4194f4ee23e415e1064
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/

Nếu màn hình output ra như trên, nghĩa là đã start thành công container hello-world

3| Xoá container

$ docker container prune

WARNING! This will remove all stopped containers.
Are you sure you want to continue? [y/N] y
Deleted Containers:
170017fd3c425700773d454942b8825e80fe96a254186117fe26ad51a2e1b457

Total reclaimed space: 0B

Leave a Reply

Your email address will not be published. Required fields are marked *