Docker/docs

[Docker] [docs] 04. 애플리케이션 공유, Docker Hub

NJ94 2023. 12. 4. 18:17

https://docs.docker.com/get-started/04_sharing_app/

 

Share the application

Sharing your image you built for your example application so you can run it else where and other developers can use it

docs.docker.com

이제 이미지를 만들었으므로 공유할 수 있습니다. Docker 이미지를 공유하려면 Docker 레지스트리를 사용해야 합니다. 기본 레지스트리는 Docker Hub이며 사용한 모든 이미지의 출처입니다.

 

저장소 만들기

1. Docker Hub 접속 > 회원가입, 로그인

 

https://hub.docker.com/

 

Docker Hub Container Image Library | App Containerization

Build and Ship any Application Anywhere Docker Hub is the world's easiest way to create, manage, and deliver your team's container applications. Create your account Signing up for Docker is fast and free. Continue with GoogleContinue with GitHubContinue wi

hub.docker.com

 

2. create repository 레포지토리 생성

3. 저장소 이름 입력 (공개 여부가 공개 인지 확인 필)

4. 만들기 선택

 

Docker Hub 이미지 등록

1. 명령어를 통해 아래의 명령어 실행

$ docker push docker/getting-started
The push refers to repository [docker.io/docker/getting-started]
An image does not exist locally with the tag: docker/getting-started

 

위의 에러 발생 시, 기존 이미지에 태그를 지정하여 다른 이름으로 지정해야 한다.

 

2. 명령어를 사용하여 Docker Hub 로그인 

$ docker login -u YOUR-USER-NAME

 

위의 명령어 입력 시,  Error: Cannot perform an interactive login from a non TTY device  에러가 발생되면, 로그인이 되어 있다고 보면된다.(정확한 이유는 찾는중)

 

3. 아래의 명령어를 사용하여 이미지에 새 이름을 docker tag를 지정한다

$ docker tag getting-started YOUR-USER-NAME/getting-started

 

4. docker push 명령어를 다시 실행

$ docker push YOUR-USER-NAME/getting-started

 

새 인스턴스에서 이미지 실행

1. Docker Hub 접속 후, 업로드된 이미지 파일 가져오기

$ docker pull YOUR-USER-NAME/getting-started

 

2. 업로드 된 이미지 컨테이너 실행

$ docker run -dp 0.0.0.0:3000:3000 YOUR-USER-NAME/getting-started

 

MAC 사용 시, 아래의 명령어로 재 빌드 필요

$ docker build --platform linux/amd64 -t YOUR-USER-NAME/getting-started .