获取镜像
获取镜像的方法一个是拉取官方镜像,一个是自己构建镜像
docker pull apache/sharding-proxy
docker run -d \
-v /usr/etc/sharding-proxy/conf:/opt/sharding-proxy/conf \
--env JVM_OPTS="-Djava.awt.headless=true" \
--env PORT=3308 -p13308:3308 \
--name sharding-proxy \
apache/sharding-proxy:latest
docker logs sharding-proxy
为容器添加数据库驱动
进入容器内部
docker exec -it sharding-proxy bash
进入到sharding-proxy容器内的lib目录
cd /opt/sharding-proxy/lib
下载jdbc的mysql驱动jar包
wget http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.48/mysql-connector-java-5.1.48.jar
exit退出容器,然后重启容器
docker restart sharding-proxy
保存容器固化成镜像
docker commit sharding-proxy 192.168.1.45:6543/com.demo/sharding-proxy:1.0.0
登录
docker login 192.168.1.45:6543 -u root -p 123456
推送镜像
docker push 192.168.1.45:6543/com.demo/sharding-proxy:1.0.0