root@devops:~# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one. Username: 아이디 입력 Password: 패스워드 입력 WARNING! Your password will be stored unencrypted in /root/.docker/config.json. Configure a credential helper to remove this warning. See https://docs.docker.com/engine/reference/commandline/login/#credentials-store Login Succeeded |
# Image가 도커에 탑재됐을 때 Container가 된다.
# Immutable 이미지를 만들고 그거 위에 새로운 걸 얹는 느낌
# Immutable 이미지에 IP 같은 것들은 들어가면 안됨
#Private host url
#Basic image
#Dockerfile … Docker build까지만 해주고, 나머지는 쿠버네티스 이용할 예정
root@labs--1234:/home/project/lab-env# pwd
/home/project/lab-env |
root@labs--1234:/home/project/lab-env# mkdir DockerLab
root@labs--1234:/home/project/lab-env# cd DockerLab
root@labs--1234:/home/project/lab-env/DockerLab# vi index.html
Hi~ My name is Hong Gil Dong |
root@labs--1234:/home/project/lab-env/DockerLab# vi Dockerfile
FROM nginx COPY index.html /usr/share/nginx/html/ |
#Dockerfile로 이미지 생성
root@labs--1234:/home/project/lab-env/DockerLab# docker build -t 도커아이디/my-nginx:v1 .
Sending build context to Docker daemon 3.072 kB Step 1/2 : FROM nginx latest: Pulling from library/nginx 33847f680f63: Pull complete dbb907d5159d: Pull complete 8a268f30c42a: Pull complete b10cf527a02d: Pull complete c90b090c213b: Pull complete 1f41b2f2bf94: Pull complete Digest: sha256:8f335768880da6baf72b70c701002b45f4932acae8d574dedfddaf967fc3ac90 Status: Downloaded newer image for nginx:latest ---> 08b152afcfae Step 2/2 : COPY index.html /usr/share/nginx/html/ ---> 9a72d6ff453a Successfully built 9a72d6ff453a Successfully tagged 도커아이디/my-nginx:v1 |
#도커 이미지 목록 확인
root@labs--1234:/home/project/lab-env/DockerLab# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE 도커아이디/my-nginx v1 9a72d6ff453a 27 seconds ago 133 MB nginx latest 08b152afcfae 13 days ago 133 MB |
# 도커 이미지 Push 1)
root@labs--1234:/home/project/lab-env/DockerLab# docker login
… Login Succeeded |
# 도커 이미지 Push 2)
root@labs--1234:/home/project/lab-env/DockerLab# docker push 도커아이디/my-nginx:v1
The push refers to repository [docker.io/도커아이디/my-nginx] deea81dd057c: Pushed e3135447ca3e: Mounted from library/nginx b85734705991: Mounted from library/nginx 988d9a3509bb: Mounted from library/nginx 59b01b87c9e7: Mounted from library/nginx 7c0b223167b9: Mounted from library/nginx 814bff734324: Mounted from library/nginx v1: digest: sha256:ad4511eda68b63ab92dc2de4bc7bea38a06af47af376ce96c23e14ab1566a1a9 size: 1777 |
#컨테이너 실행
root@labs--1234:/home/project/lab-env/DockerLab# docker run --name=my-nginx -d -p 8072:80 도커아이디/my-nginx:v1
3e9bac040be41b7daa5ee1d5bde74e526db79ab052482593f7ced7aadb32916e |
root@labs--1234:/home/project/lab-env/DockerLab# curl localhost:8072
Hi~ My name is Hong Gil Dong |
#모든 컨테이너 한번에 삭제 (중지 후 삭제)
root@labs--1234:/home/project/lab-env/DockerLab# docker container rm $(docker ps -a -q)
Error response from daemon: You cannot remove a running container 3e9bac040be41b7daa5ee1d5bde74e526db79ab052482593f7ced7aadb32916e. Stop the container before attempting removal or force remove |
# 컨테이너 종료
root@labs--1234:/home/project/lab-env/DockerLab# docker stop
3e9bac040be41b7daa5ee1d5bde74e526db79ab052482593f7ced7aadb32916e 3e9bac040be41b7daa5ee1d5bde74e526db79ab052482593f7ced7aadb32916e |
#모든 컨테이너 한번에 삭제 (중지 후 삭제)
root@labs--1234:/home/project/lab-env/DockerLab# docker container rm $(docker ps -a -q)
3e9bac040be4 |
# 실행중인 컨테이너 확인
root@labs--1234:/home/project/lab-env/DockerLab# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
root@labs--1234:/home/project/lab-env/DockerLab# docker run --name=my-nginx -d -p 8087:80 도커아이디/my-nginx:v19b5bf23d92f3581c67e1164873612ce7e149a5e12793011d734639cef4a730ff
'IT > VMware | 가상화' 카테고리의 다른 글
VMware/Citrix GPU License 가이드 (0) | 2023.01.10 |
---|---|
DevOps를 위한 도커와 쿠버네티스 1-3. 컨테이너 생성 따라하기 (0) | 2021.08.11 |
DevOps를 위한 도커와 쿠버네티스 1-2. Linux Network Namespace (0) | 2021.08.11 |
vCenter 업그레이드 작업 6.0 to 6.7 (flash EOL) (0) | 2021.08.09 |
VMware vCenter 비정상 상태 조치 (0) | 2021.01.19 |