获取镜像

获取镜像的方法一个是拉取官方镜像,一个是自己构建镜像

  1. docker pull apache/sharding-proxy
  1. docker run -d \
  2. -v /usr/etc/sharding-proxy/conf:/opt/sharding-proxy/conf \
  3. --env JVM_OPTS="-Djava.awt.headless=true" \
  4. --env PORT=3308 -p13308:3308 \
  5. --name sharding-proxy \
  6. apache/sharding-proxy:latest
  1. docker logs sharding-proxy

为容器添加数据库驱动

进入容器内部

  1. docker exec -it sharding-proxy bash

进入到sharding-proxy容器内的lib目录

  1. cd /opt/sharding-proxy/lib

下载jdbc的mysql驱动jar包

  1. wget http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.48/mysql-connector-java-5.1.48.jar

exit退出容器,然后重启容器

  1. docker restart sharding-proxy

保存容器固化成镜像

  1. docker commit sharding-proxy 192.168.1.45:6543/com.demo/sharding-proxy:1.0.0

登录

  1. docker login 192.168.1.45:6543 -u root -p 123456

推送镜像

  1. docker push 192.168.1.45:6543/com.demo/sharding-proxy:1.0.0