You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Current »


목차


Dockerfile 작성


Dockerfile

[root@lab-centos-on-docker-vm workspace]# cat Dockerfile
FROM tomcat:9-jre8-alpine
COPY index.html /usr/local/tomcat/webapps/ROOT

CMD ["catalina.sh", "run"]


index.html

[root@lab-centos-on-docker-vm workspace]# cat index.html
hello 2019-12-05


Build & Tag 생성


docker build -t sooabia/sanse-tomcat9:2 .


[root@lab-centos-on-docker-vm workspace]# docker build -t sooabia/sanse-tomcat9:2 .
Sending build context to Docker daemon  3.072kB
Step 1/3 : FROM tomcat:9-jre8-alpine
 ---> 387f9d021d3a
Step 2/3 : COPY index.html /usr/local/tomcat/webapps/ROOT
 ---> efd6f75af6db
Step 3/3 : CMD ["catalina.sh", "run"]
 ---> Running in f5add9960acd
Removing intermediate container f5add9960acd
 ---> 4f2581f1877d
Successfully built 4f2581f1877d
Successfully tagged sanse-tomcat9:2

새로만든 Docker images 실행해보기

docker run -d -p 80:8080 sooabia/sanse-tomcat9:2

[root@lab-centos-on-docker-vm workspace]# docker run -d -p 80:8080 sooabia/sanse-tomcat9:2
9859a78bb9bebe5243b8639fb11a45d1e517376ca20293d1f35e7296d9dc9b2e

Docker Hub에 올리기

  • Docker hub로그인
[root@lab-centos-on-docker-vm workspace]# 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: sooabia
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

  • Docker hub에 업로드
[root@lab-centos-on-docker-vm workspace]# docker push sooabia/sanse-tomcat9:2
The push refers to repository [docker.io/sooabia/sanse-tomcat9]
66e6933100ba: Pushed
b7d850202de0: Mounted from library/tomcat
d1d0b1719b96: Mounted from library/tomcat
48988bb7b861: Mounted from library/tomcat
edd61588d126: Mounted from library/tomcat
2: digest: sha256:7c98ffb33f01e4a67d1df8eb9dfa10792b61949c5636069eb504a06b14af110c size: 1781

Windows환경에서 실행해 보기


  • docker login
D:\workspace>docker login
Authenticating with existing credentials...
Login Succeeded
  • docker pull sooabia/sanse-tomcat9:2
D:\workspace>docker pull sooabia/sanse-tomcat9:2
2: Pulling from sooabia/sanse-tomcat9
e7c96db7181b: Already exists
f910a506b6cb: Already exists
b6abafe80f63: Pull complete
d8c966ddef98: Pull complete
15b754e99755: Pull complete
4227393eb352: Pull complete
8a7c757fa46b: Pull complete
Digest: sha256:7c98ffb33f01e4a67d1df8eb9dfa10792b61949c5636069eb504a06b14af110c
Status: Downloaded newer image for sooabia/sanse-tomcat9:2
docker.io/sooabia/sanse-tomcat9:2
  • docker run -d -p 80:8080 sooabia/sanse-tomcat9:2
D:\workspace>docker run -d -p 80:8080 sooabia/sanse-tomcat9:2
419278f73d6f110321c57d63a65606d363c545ae909ed39d09ce1ed834af1509
  • No labels