【docker】建立Dockerfile並push到docker-hub

建立 dockerfile

Dockerfileweb

PS: 文件名字必須是這樣Dockerfiledocker

FROM tomcat:8.0
COPY index.jsp  /usr/local/tomcat/webapps/ROOT
EXPOSE 8080

index.jsptomcat

<%
out.println("Hello World, V1");
%>

build 並測試app

The docker build command processes this file generating a Docker Image in your Local Image Cache, which you can then start-up using the docker run command, or push to a permanent Image Repository.curl

docker build 建立一個docker鏡像,這個鏡像能夠在你本地運行。webapp

$docker build -t mytomcat:1.0 .

$docker run -p 8080:8080 -d mytomcat:1.0

$curl localhost:8080

push 到 docker hub

註冊一個帳號jsp

Build image 測試

Docker loginui

輸入用戶名、密碼this

Docker push

第一步:修改 tag 名稱

// 必須先修改 tag 名稱
docker tag firstimage YOUR_DOCKERHUB_NAME/firstimage

舉例:
docker tag mytomcat:1.0 preparedman/mytomcat:1.0

第二步:push

docker push YOUR_DOCKERHUB_NAME/firstimage

舉例:docker push preparedman/mytomcat:1.0

Docker 測試

https://cloud.docker.com/u/preparedman/repository/docker/preparedman/mytomcat

https://stackoverflow.com/que...

相關文章
相關標籤/搜索