Docker基本用法
https://www.cnblogs.com/codexiaoyi/p/13395719.html
docker build -t yinwensheng/yihuiwebsite:v1 .
docker push yinwensheng/yihuiwebsite:v1
docker login
docker images
docker exec -it f14e9a56cc03 redis-cli
/usr/local/docker
/marvel/local
version: "3.3"
services:
adminer:
image: adminer
restart: always
ports:
- 8088:8080
sonarqube6.7:
image: sonarqube:latest
container_name: sonarqube
ports:
- "9000:9000"
- "9092:9092"
volumes:
- /etc/localtime:/etc/localtime:ro
environment:
- SONARQUBE_JDBC_USERNAME=root
- SONARQUBE_JDBC_PASSWORD=*****
- SONARQUBE_JDBC_URL=jdbc:mysql://localhost:3306/hzc?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false
![](https://img2018.cnblogs.com/blog/565032/201907/565032-20190726143354012-1985758119.png)
![](https://img2018.cnblogs.com/blog/565032/201907/565032-20190726143440547-484577485.png)
![](https://img2018.cnblogs.com/blog/565032/201907/565032-20190726143427735-1478830495.png)
docker exec -it 189e7fbaf9f3 bash mysql
FROM java:8
VOLUME /tmp
ADD marvel-eureka-1.0.0-RELEASE.jar aevenger.jar
# RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
RUN /bin/bash -c 'touch /aevenger.jar'
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./
urandom","-Dspring.profiles.active=k8s","-Dmarvel-eureka-01.hostname=test-marvel-1","-Dmarvel-eureka-02.hostname=test-marvel-2","-jar","/aevenger.jar"]
EXPOSE 8761
ENTRYPOINT
入口点,在指定容器启动程序及参数
场景一:让镜像变成像命令一样使用。
场景二:应用运行前的准备工作。
可多次设置,但只有最后一个有效。
ENTRYPOINT[“executable”,“param1”,“param2”]
ENTRYPOINT command param1 param2
ENTRYPOINT [“java”,"-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
为了缩短 Tomcat 的启动时间,添加 java.security.egd的系统属性指向 /dev/urandom作为 ENTRYPOINT
cat docker-compose.yml
version: '2'
services:
mysql:
network_mode: "host"
environment:
MYSQL_ROOT_PASSWORD: "*****"
image: "docker.io/mysql:5.6"
restart: always
volumes:
- "./db:/var/lib/mysql"
- "./my.cnf:/etc/my.cnf"
ports:
- "3306:3306"
- Docker从基础镜像运行一个容器。
- 执行一条指令,对容器做出修改。
- 执行类似docker commit的操作,提交一个新的镜像层。
- Docker再基于刚提交的镜像层运行一个新容器。
- 执行Dockerfile中的下一条指令,直到所有指令都执行完毕
From ubuntu:latest MAINTAINER WZL RUN apt-get update && apt-get install -y nginx RUN echo 'Hi, I am in your container' > /var/www/html/index.nginx-debian.html EXPOSE 80