초보자를 위한 Docker 튜토리얼: 기본 사항, Archi강의, 컨테이너

⚡ 스마트 요약

Docker is a containerization platform that packages applications and their dependencies into portable, lightweight containers. This overview explains Docker architecture, installation on Ubuntu, essential commands, and how containers differ from traditional virtual machines for faster software delivery.

  • 🐳 컨테이너화: Docker virtualizes at the operating-system level, so containers share the host kernel and use fewer resources than virtual machines.
  • 🧱 Archi강의: The Docker engine (dockerd), images, registries, and containers form the client-server architecture behind every Docker workflow.
  • 📦 Images and Containers: An image is a read-only template, while a container is a running copy, and one image can start many containers.
  • 🗄️ 레지스트리: Docker Hub stores public and private images, giving you millions of ready-to-use images to pull and run.
  • ⚙️ 설치: On Ubuntu you add the Docker APT repository and GPG key, then install the docker-ce package with apt-get.
  • ⌨️ 핵심 명령어: Manage containers with docker pull, run, start, stop, ps, stats, and images from the command line.

Docker tutorial for beginners covering architecture, installation on Ubuntu, and basic container commands

Docker is one of the most popular containerization platforms used in modern DevOps (개발 운영) and cloud workflows. This Docker tutorial for beginners explains what Docker is, how the Docker architecture works, how to install Docker on Ubuntu, and the basic commands used to manage images and containers.

Docker는 무엇입니까?

도커 is a software development platform for virtualization that lets multiple operating systems run on the same host. It helps you separate infrastructure from applications so you can deliver software quickly. Unlike hypervisors, which are used to create virtual machines (VMs), Docker performs virtualization at the system level using units called Docker containers.

Docker containers run on top of the host operating system, as shown in the image below. This improves both efficiency and security. You can also run more containers than virtual machines on the same infrastructure, because containers use fewer resources.

Docker와 Hypervisor의 가상화
Docker와 Hypervisor의 가상화

Unlike VMs, which can communicate directly with the host hardware (for example, an Ethernet adapter that creates more virtual adapters), Docker containers run in an isolated environment on top of the host OS. Even if your host runs Windows, 당신은 실행할 수 있습니다 Linux images inside containers with the help of Hyper-V, which automatically creates a small VM to virtualize the base image.

Now that you know what Docker is, let us look at the main reasons teams choose it.

도커를 사용하는 이유는 무엇입니까?

Here are the key reasons to use Docker:

  • Docker is software used for virtualization, allowing multiple 운영체제 to run on the same host.
  • Docker is a client-server application, which means clients communicate with a server.
  • Docker images act as the “source code” for containers; you use them to build.
  • Docker supports two types of registries: public and private.
  • Containers are the organizational units of Docker. In simple terms, an image is a template and a container is a copy of that template, so you can run multiple containers from the same image.

These benefits come from the way Docker is designed. The following section breaks down the Docker architecture and its core components.

도커 Archi강의

Now, in this Docker container tutorial, let us look at the main components of the Docker architecture.

도커 Architecture components: engine, images, registries, and containers

도커 Archi강의

도커 엔진

Docker is a client-server application, which means we have clients that relay requests to a server. The Docker daemon, called dockerd, is the Docker engine that represents the server. The daemon and the clients can run on the same or a remote host, and they communicate through a command-line client binary and a full RESTful API that interacts with dockerd.

도커 이미지

Docker images are the “source code” for our containers; we use them to build containers. Images can have software pre-installed, which speeds up deployment. They are portable, and you can use existing images or build your own.

도커 레지스트리

Docker stores the images we build in registries. There are public and private registries. Docker has a public registry called 도커 허브, where you can also store images privately. Docker Hub has millions of images that you can start using right away.

고정 컨테이너

Containers are the organizational units of Docker and one of its basic concepts. When we build an image and run it, we are running it inside a container. The container analogy is used because of the portability of the software running inside it: you can move, “ship”, modify, manage, create, or destroy it, just as cargo ships handle real containers.

간단히 말해서 이미지는 템플릿이고 컨테이너는 해당 템플릿의 복사본입니다. 동일한 이미지의 여러 컨테이너(사본)를 가질 수 있습니다.

The interaction between these different components shows how Docker container technology works together. Commands such as docker pull and docker run, which we cover later, let you manage this workflow.

With the architecture in mind, let us install Docker so you can try these components yourself.

Linux에 Docker를 설치하는 방법/Ubuntu

Below is a step-by-step Docker installation process on Linux/Ubuntu:

단계 1) To install Docker, you need the Docker team’s DEB packages. First, some prerequisite Ubuntu packages are required. Use the command below to install them.

$ sudo apt-get install \
apt-transport-https \
ca-certificates curl \
software-properties-common

*"\" 기호는 필요하지 않습니다. 새 줄에 사용됩니다. 원하는 경우 "\"를 사용하지 않고 한 줄에만 명령을 작성할 수 있습니다.

단계 2) Add the official Docker GPG key with the fingerprint. Use the below Docker command to enter the GPG key.

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

단계 3) Next, add the Docker APT repository using the command below.

$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"

You may be prompted to confirm that you wish to add the repository and have the GPG key automatically added to your host. The lsb_release command should populate the Ubuntu 호스트의 배포 버전.

단계 4) After adding the GPG key, update the APT sources using the below Docker command.

$ sudo apt-get update

You can now install the Docker package itself.

단계 5) Once the APT sources are updated, start installing the Docker packages on Ubuntu using the below Docker command.

$ sudo apt-get install docker-ce

The command above installs Docker and other required packages. Before Docker 1.8.0, the package name was lxc-docker, and between Docker 1.8 and 1.13, the package name was docker-engine.

알림: Docker for Windows 필요 Windows 10 Pro 또는 Enterprise 버전 14393, 또는 Windows Server 2016 RTM, to run.

기본 Docker 명령을 사용하여 Docker를 사용하는 방법

Here is how to use Docker with a few basic Docker commands.

The most basic command you should run after installing Docker is docker info, as mentioned earlier.

$ sudo docker info

You should get a result similar to the following.

Use Docker using basic Docker commands, showing docker info output

As shown in the Docker example above, we can see information about Docker containers: how many are running, paused, or stopped, and how many images have been downloaded. Now let us get our first image.

$ sudo docker pull alpine

With this command, we are telling Docker to download the image alpine, pulling it from the public registry in the latest version, which is set by default.

*alpine은 완전한 패키지 인덱스와 크기가 5MB에 불과한 Alpine Linux 기반의 최소 Docker 이미지입니다.

If we want to run the image as a container, we use the following command.

$ sudo docker run -i -t alpine /bin/bash

Running the command sends us directly to the alpine terminal. The -i flag keeps STDIN open from the container even when you are not attached to it; this persistent standard input is one half of what you need for an interactive shell. The -t flag is the other half and instructs Docker to assign a pseudo-tty to the container. Together they give us an interactive shell in the new container. We exit the container with a simple exit command.

Now, in this Docker basics tutorial, we can try running an Ubuntu 영상.

$ sudo docker run -it ubuntu /bin/bash

Notice that Docker checks for the image locally, and if it is not there, the image is pulled from the image library automatically. Once again, we have an interactive shell running. We can also name containers as we run them.

$ sudo docker run –-name our_container -it ubuntu /bin/bash

Then we exit again. We can also run a container we previously created without an interactive shell.

$ sudo docker start container_name

And we stop the container by writing docker stop container_name.

$ sudo docker stop container_name

If we want to see all running containers, we simply run the following.

$ docker ps

For all containers, we add “-a” at the end of the same command, like docker ps -a. This command shows the container ID, which image it uses, when it was created, its running status, exposed ports, and a randomly generated name for easier management.

When we run containers, we often want to know how many resources they are using. For that purpose, we can use the following command.

$ docker stats

You can also see which images you have downloaded locally, along with information about them.

$ sudo docker images

The command in the Docker example above displays each Docker image with a tag showing the image version, a distinctive image ID, the creation date, and the image size.

To understand why containers are such an improvement, it helps to look at how virtualization evolved.

가상화란 무엇입니까?

Earlier, deploying a service was slow and painful. Developers would write code, and then the operations team would deploy it on bare-metal machines, where they had to watch out for library versions, patches, and language compilers so the code would work. If there were bugs or errors, the process would start all over again: the developers would fix the issue, and the operations team would redeploy.

Things improved with the creation of hypervisors. Hypervisors run multiple 가상 머신, or VMs, on the same host, which may be running or turned off. VMs greatly reduced the waiting time for deploying code and fixing bugs, but the real game changer was Docker containers.

Docker’s popularity is also driven by orchestration tools that manage containers at scale, such as Kubernetes. Before moving on, here is a quick reference of the most important Docker commands.

중요한 Docker 명령

다음은 중요한 Docker 명령입니다.

Command 기술설명
도커 정보 정보사령부
도커 풀 이미지 다운로드
docker run -i -t image_name /bin/bash 이미지를 컨테이너로 실행
도커 시작 our_container 컨테이너 시작
docker stop 컨테이너_이름 컨테이너 중지
도커 ps List of all running containers
도커 통계 컨테이너 정보
도커 이미지 다운로드한 이미지 목록
도커 정리 실행 중인 모든 컨테이너를 종료합니다.

Also, read these Docker 취업 면접 질문과 답변 for freshers as well as experienced professionals.

자주 묻는 질문

A Docker container shares the host operating system kernel and isolates only the application, so it is lightweight and starts in seconds. A virtual machine bundles a full guest operating system, which makes it larger, slower to boot, and more resource-intensive.

A Dockerfile is a plain-text script containing instructions such as FROM, RUN, COPY, and CMD. Docker reads these instructions to build an image automatically. Each line adds a layer, letting you reproduce the same environment on any machine.

Docker Compose defines and runs multi-container applications using a single YAML file. You describe each service, network, and volume once, then start everything with the docker compose up command. It is ideal for local development and testing of connected services.

Docker builds and runs individual containers, while Kubernetes orchestrates many containers across a cluster. Kubernetes adds automatic scaling, self-healing, and load balancing. In practice, Docker packages the application and Kubernetes manages it in production.

Docker Engine is free and open source under the Apache 2.0 license. Docker Desktop is free for personal use, education, and small businesses, but larger companies need a paid subscription. Docker Hub offers both free and paid image-hosting plans.

Docker runs natively on Linux and is supported on Windows macOS through Docker Desktop. On Windows and Mac, Docker uses a lightweight virtual machine to run the Linux kernel that containers require. Most container images are Linux-based.

AI assistants generate Dockerfiles, docker-compose files, and CLI commands from plain-language prompts. They also read build logs and container errors, explain the cause, and suggest fixes. Always review generated configuration for correct image tags, paths, and security before running it.

예. GitHub 부조종사 and ChatGPT can draft Dockerfiles and Compose files from a short comment or description. They speed up boilerplate, but you should verify base images, versions, and best practices, because generated snippets may use outdated defaults.

이 게시물을 요약하면 다음과 같습니다.