사용 기술: ubuntu:22.04
1. 도커 설치 및 테스트
ubuntu@ip-172-31-34-113:~$ sudo apt-get update
ubuntu@ip-172-31-34-113:~$ sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
ubuntu@ip-172-31-34-113:~$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
ubuntu@ip-172-31-34-113:~$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
ubuntu@ip-172-31-34-113:~$ sudo apt-get install docker-ce docker-ce-cli containerd.io
ubuntu@ip-172-31-34-113:~$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
719385e32844: Pull complete
Digest: sha256:a13ec89cdf897b3e551bd9f89d499db6ff3a7f44c5b9eb8bca40da20eb4ea1fa
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/
2. 도커 sudo 권한 없이 사용하기
ubuntu@ip-172-31-34-113:~$ sudo usermod -aG docker ubuntu
ubuntu@ip-172-31-34-113:~$ sudo service docker restart
ubuntu@ip-172-31-34-113:~$ sudo su -
ubuntu@ip-172-31-34-113:~$ su - ubuntu
ubuntu@ip-172-31-34-113:~$ docker container 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.
(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/
3. 도커 컴포즈 설치
ubuntu@ip-172-31-34-113:~$ sudo curl -L
"https://github.com/docker/compose/releases/download/2.19.1/docker-compose-$(uname -s)-$(uname -m)"
-o /usr/local/bin/docker-compose
ubuntu@ip-172-31-34-113:~$ sudo chmod +x /usr/local/bin/docker-compose
ubuntu@ip-172-31-34-113:~$ sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
ubuntu@ip-172-31-34-113:~$ docker-compose -v
docker-compose version 2.19.1
만약 wsl에서 위와 같은 오류가 발생할 경우
stopping healthcheck following graceful shutdown module=libcontainerd
failed to start daemon: Error initializing network controller: error obtaining controller instance: failed to register "bridge" driver: unable to add return rule in DOCKER-ISOLATION-STAGE-1 chain: (iptables failed: iptables --wait -A DOCKER-ISOLATION-STAGE-1 -j RETURN: iptables v1.8.7 (nf_tables): RULE_APPEND failed (No such file or directory): rule in chain DOCKER-ISOLATION-STAGE-1
(exit status 4))
명령어로 해결되었습니다.
sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
'인프라 > Docker' 카테고리의 다른 글
Docker ubuntu에 MySql 사용하기 (1) | 2023.12.05 |
---|---|
윈도우에서 docker in docker 사용 방법 (0) | 2023.09.02 |
k8s 실습을 위한 SpringBoot Dockerfile 작성 (0) | 2023.08.25 |
Docker를 통한 laravel(PHP) 개발 환경 구축 (0) | 2023.07.02 |
Docker를 활용한 노드(React) 실행 환경 구축 (0) | 2023.06.08 |