hyperskill - Run the "hello-world" docker container
이번 주제에서는, hello-world 라는 이미지인 컨테이너를 실행 할 겁니다.
그리고 이는 도커를 시작하는 데 가장 유명한 이미지 중 하나입니다.
당신이 이 이미지를 Docker Hub 를 얻을 수 있으며, 당신의 컴퓨터를 실행 할 수 있습니다.
Check installation - 설치 확인
사용 가능한 하위 명령어들을 나열하기 위해서, 이 명령어를 파라미터 없이 실행하세요 :
$ docker
Usage: docker [OPTIONS] COMMAND
A self-sufficient runtime for containers
Common Commands:
run Create and run a new container from an image
exec Execute a command in a running container
ps List containers
build Build an image from a Dockerfile
pull Download an image from a registry
push Upload an image to a registry
images List images
login Log in to a registry
logout Log out from a registry
search Search Docker Hub for images
version Show the Docker version information
info Display system-wide information
Management Commands:
builder Manage builds
buildx* Docker Buildx
checkpoint Manage checkpoints
compose* Docker Compose
container Manage containers
context Manage contexts
debug* Get a shell into any image or container
desktop* Docker Desktop commands (Alpha)
dev* Docker Dev Environments
extension* Manages Docker extensions
feedback* Provide feedback, right in your terminal!
image Manage images
init* Creates Docker-related starter files for your project
manifest Manage Docker image manifests and manifest lists
network Manage networks
plugin Manage plugins
sbom* View the packaged-based Software Bill Of Materials (SBOM) for an image
scout* Docker Scout
system Manage Docker
trust Manage trust on Docker images
volume Manage volumes
Swarm Commands:
config Manage Swarm configs
node Manage Swarm nodes
secret Manage Swarm secrets
service Manage Swarm services
stack Manage Swarm stacks
swarm Manage Swarm
Commands:
attach Attach local standard input, output, and error streams to a running container
commit Create a new image from a container's changes
cp Copy files/folders between a container and the local filesystem
create Create a new container
diff Inspect changes to files or directories on a container's filesystem
events Get real time events from the server
export Export a container's filesystem as a tar archive
history Show the history of an image
import Import the contents from a tarball to create a filesystem image
inspect Return low-level information on Docker objects
kill Kill one or more running containers
load Load an image from a tar archive or STDIN
logs Fetch the logs of a container
pause Pause all processes within one or more containers
port List port mappings or a specific mapping for the container
rename Rename a container
restart Restart one or more containers
rm Remove one or more containers
rmi Remove one or more images
save Save one or more images to a tar archive (streamed to STDOUT by default)
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop one or more running containers
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
top Display the running processes of a container
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
wait Block until one or more containers stop, then print their exit codes
Global Options:
--config string Location of client config files (default "/Users/gongdamhyeong/.docker")
-c, --context string Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with "docker context use")
-D, --debug Enable debug mode
-H, --host list Daemon socket to connect to
-l, --log-level string Set the logging level ("debug", "info", "warn", "error", "fatal") (default "info")
--tls Use TLS; implied by --tlsverify
--tlscacert string Trust certs signed only by this CA (default "/Users/gongdamhyeong/.docker/ca.pem")
--tlscert string Path to TLS certificate file (default "/Users/gongdamhyeong/.docker/cert.pem")
--tlskey string Path to TLS key file (default "/Users/gongdamhyeong/.docker/key.pem")
--tlsverify Use TLS and verify the remote
-v, --version Print version information and quit
Run 'docker COMMAND --help' for more information on a command.
For more help on how to use Docker, head to https://docs.docker.com/go/guides/
또한, 당신이 사용하고 있는 운영체제에 Docker 가 설치되어 있는지 확실히 하기 위해서,
맡의 명령어를 실행할 수 있으며, 게다가 도커의 버전과 설치를 확인할 수 있습니다 :
$ docker --version
Docker version 27.1.1, build 6312585
Pull images - 이미지 가져오기
기본적으로, 설치 이후에 당신의 컴퓨터에는 이미지가 없습니다.
이러한 상황은, 당신이 컨테이너를 생성하기 위해 이미지가 필요하다는 것입니다.
또한 당신은 다양한 Docker 레포지토리 로부터 이들을 당겨올(pull) 수 있습니다.
이 명령어와 함께, 당신은 도커 레지스트리로부터 모든 이미지를 당겨올 수 있습니다.
docker pull
명령어를 실행 한 이후에,
당신의 컴퓨터에 있는 레지스트리로부터 선택된 이미지를 당겨오는 방법을 볼 수 있습니다.
도커를 설치 한 이후에 스스로의 컴퓨터에 이미지를 당겨(pull)온 적이 있어야 볼 수 있습니다.
이미지를 당겨오는 프로세스의 시간은 인터넷의 속도에 달려 있습니다.
$ docker pull hello-world
Using default tag: latest
What's next:
View a summary of image vulnerabilities and recommendations → docker scout quickview hello-world
Cannot connect to the Docker daemon at unix:///Users/gongdamhyeong/.docker/run/docker.sock. Is the docker daemon running?
현재 나는 Docker 엔진을 실행하지 않았기 때문에, 밑에
unix:///Users/gongdamhyeong/.docker/run/docker.sock.
가 뜬다.
Docker Desktop or Docker Engine 을 실행 한 이후에 실행 :
Using default tag: latest
latest: Pulling from library/hello-world
478afc919002: Pull complete
Digest: sha256:53cc4d415d839c98be39331c948609b659ed725170ad2ca8eb36951288f81b75
Status: Downloaded newer image for hello-world:latest
docker.io/library/hello-world:latest
What's next:
View a summary of image vulnerabilities and recommendations → docker scout quickview hello-world
docker images
명령어로, 당신의 운영체제에 설치된 도커 이미지들을 나열 할 수 있습니다.
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker/desktop-kubernetes kubernetes-v1.30.2-cni-v1.4.0-critools-v1.29.0-cri-dockerd-v0.3.11-1-debian 5ef3082e902d 7 weeks ago 419MB
registry.k8s.io/kube-apiserver v1.30.2 84c601f3f72c 2 months ago 112MB
registry.k8s.io/kube-scheduler v1.30.2 c7dd04b1bafe 2 months ago 60.5MB
registry.k8s.io/kube-controller-manager v1.30.2 e1dcc3400d3e 2 months ago 107MB
registry.k8s.io/kube-proxy v1.30.2 66dbb96a9149 2 months ago 87.9MB
registry.k8s.io/ingress-nginx/controller <none> 6505abd14fdf 6 months ago 279MB
registry.k8s.io/ingress-nginx/kube-webhook-certgen <none> 1a024e390dd0 6 months ago 53.2MB
registry.k8s.io/etcd 3.5.12-0 014faa467e29 6 months ago 139MB
code-creature-app latest 7bb48b8d9c60 6 months ago 661MB
hello-world latest ee301c921b8a 16 months ago 9.14kB
registry.k8s.io/pause 3.9 829e9de338bd 22 months ago 514kB
mysql 8.0.30 1699df6c42a3 23 months ago 494MB
docker101tutorial latest e12d75554167 23 months ago 27.5MB
kubernetesui/dashboard v2.6.0 09df423d5a37 2 years ago 245MB
kubernetesui/metrics-scraper v1.0.8 a422e0e98235 2 years ago 42.3MB
docker/desktop-storage-provisioner v2.0 c027a58fa0bb 3 years ago 39.8MB
...
...
...
Run container - 컨테이너 실행하기
서버에, 혹은 로컬 컴퓨터에 이미지를 가지고 있을 때,
우리는 docker run
명령어를 통해 컨테이너를 생성하는데 사용 할 수 있습니다.
우리가 해야 할 것은 docker run
명령어 이후에 이미지의 이름을 입력하는 것입니다.
이 명령어는 우리가 제공한 이미지로부터 새로운 컨테이너를 생성합니다.
$ docker run hello-world
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.
(arm64v8)
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/
내부의 메세지를 살펴보면,
이 메세지가 보이는 것은, 당신이 올바르게 설치한 후 실행했다는 것입니다.
$ docker run -it ubuntu bash
를 실행하면 내부의 컨테이너와 상호작용할 수 있습니다.
우리는 docker run
명령어에 특정한 파라미터들을 추가할 수 있습니다.
이러한 파라미터들을 살펴 봅시다 :
-d
: 백그라운드에서 컨테이너 실행시키기-w
: 컨테이너 내부에서 실행 디렉토리 제공하기
예를 들어, 만약 우리가 -d
파라미터를 명령어에 추가한다면,
컨테이너는 백그라운드에서 실행됩니다 :
$ docker run -d hello-world
docker run hello-world
명령어를 실행 한 이후에,
우리는 이미지 파일의 사이트가 작성되어 있는 아티클을 맞닥들일 겁니다.
이는 우리가 hello-world
도커 이미지로부터 컨테이너를 실행했다는 의미입니다.
Conclusion - 결론
이번 주제에서는, 우리가 도커에서 이미지 파일을 끌어오는 법, 그리고 이러한 이미 파일을 실행하는 법을 보았습니다.
이러한 것들을 쉬운 명령어로 배우는 것은 당신이 미래에 사용할 더 복잡한 명령어에 도움을 줄 겁니다.
words to remember
이번엔 없었음.
'Hyperskill - 컴퓨터 CS 및 영어 독해 > Introduction to Docker' 카테고리의 다른 글
Docker build and docker tag - 도커 이미지 기초 지식 (1) | 2024.08.31 |
---|---|
Basic operations with a container - 도커 컨테이너 기초 명령어 (0) | 2024.08.30 |
Introduction to docker and installation (0) | 2024.08.27 |
Containers - 컨테이너 기초 의미 (0) | 2024.08.23 |
Globbing - 글로빙 (0) | 2024.08.21 |