标签:targe 生效 creat get 数据 group 官方 and logs
RUN groupadd -r mysql && useradd -r -g mysql mysql
ENV MYSQL_MAJOR 5.7
LABEL email="itlf2019@163.com" LABEL name="itlf2019"
OLUME /var/lib/mysql
COPY docker-entrypoint.sh /usr/local/bin/
ADD application.yml /etc/itcrazy2016/
WORKDIR /usr/local
WORKDIR tomcat
RUN touch test.txt
WORKDIR /root
ADD app.yml test/
CMD ["mysqld"] 或CMD mysqld
ENTRYPOINT ["docker-entrypoint.sh"]
(1)创建一个Spring Boot项目 (2)写一个controller (3)mvn clean package打成一个jar包 在target下找到"dockerfile-demo-0.0.1-SNAPSHOT.jar" (4)在docker环境中新建一个目录"first-dockerfile" (5)上传"dockerfile-demo-0.0.1-SNAPSHOT.jar"到该目录下,并且在此目录创建Dockerfile (6)创建Dockerfile文件,编写内容 FROM openjdk:8 MAINTAINElf2019" COPY spring-boot-images-0.0.1-SNAPSHOT.jar dockerfile-image.jar CMD ["java","-jar","dockerfile-image.jar"] (7)基于Dockerfile构建镜像 docker build -t test-docker-imag 8080:8080 test-docker-image (9)查看启动日志docker logs user01 (10)宿主机上访问curl localhost:8080/dockerfile hello docker 或外部 http://192.168.1.104:8080/dockerfile (11)还可以再次启动一个 docker run -d --name user02 -p 8081:8080 test-docker-image
docker stop user02
docker run -d --name user02 -p 8081:8080 test-docker-image 报错Conflict. The container name user02
docker rm fb087642b497(该containerID) 或者 docker restart user02(镜像名)
(12)docker ps 查看运行的容器 或 docker ps -as 查看所有存在的容器
(13)进如容器 docker exec -it test-docker-image sh
docker ps -as 查看所有存在的容器
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES SIZE 79cc86642500 test-docker-image "java -jar dockerfil…" 10 minutes ago Up 10 minutes 0.0.0.0:8080->8080/tcp user 32.8kB (virtual 504MB) 4d9c41573d9a test-docker-image "java -jar dockerfil…" 38 minutes ago Created test-docker-image2 0B (virtual 504MB) beac0c4f46a9 test-docker-image "java -jar dockerfil…" 42 minutes ago Up 42 minutes 0.0.0.0:6666->8080/tcp test-docker-image 32.8kB (virtual 504MB) 0f95d1856b08 tomcat "catalina.sh run" 2 hours ago Exited (143) 13 minutes ago mytomcat 57.5kB (virtual 507MB) 729964e122ad mysql:5.5 "docker-entrypoint.s…" 3 hours ago Up 3 hours 0.0.0.0:3306->3306/tcp mysql02 127B (virtual 205MB) 2e06bb215086 mysql "docker-entrypoint.s…" 3 hours ago Exited (0) 3 hours ago mysql01 0B (virtual 456MB)
标签:targe 生效 creat get 数据 group 官方 and logs
原文地址:https://www.cnblogs.com/flgb/p/12153763.html