1. 程式人生 > >Docker搭建各平臺的啟動命令集錦

Docker搭建各平臺的啟動命令集錦

文章目錄


docker檔案放置規劃

/usr/local/docker-compose/:存放各軟體的docker-compose.yml檔案,子目錄以各軟體名命名
/usr/local/:存放各軟體的掛載資料的目錄,子目錄以各軟體命名

MySQL

  • mysql主從啟動命令
mkdir -p /usr/local/mysql/master-data && chown -R 200 /usr/local/mysql/master-data
docker run -tid \
--name mysql-master \
--privileged=
true \ -v /usr/local/mysql/master-data:/var/lib/mysql \ -p 3306:3306 \ -e MYSQL_ROOT_PASSWORD=root \ -d dalomao/mysql-master:5.7 mkdir -p /usr/local/mysql/slave-data && chown -R 200 /usr/local/mysql/slave-data docker run -tid \ --name mysql-slave \ --privileged=true \ -v /usr/local/mysql/slave-data:/var/lib/mysql \ -p 3307:3306 --link mysql-master:master \ -e MYSQL_ROOT_PASSWORD=
root \ -d dalomao/mysql-slave:5.7
  • mysql主從啟動命令(自定義my.cnf)
    my.cnf要放在對應的宿主機目錄下,如/usr/local/mysql/master-etc
mkdir -p /usr/local/mysql/master-data && chown -R 200 /usr/local/mysql/master-data
mkdir -p /usr/local/mysql/master-etc && chown -R 200 /usr/local/mysql/master-etc
docker run -tid \
--name mysql-master \
--privileged=
true \ -v /usr/local/mysql/master-data:/var/lib/mysql \ -v /usr/local/mysql/master-etc:/etc/mysql/conf.d \ -p 3306:3306 \ -e MYSQL_ROOT_PASSWORD=root \ -d dalomao/mysql-master:5.7 mkdir -p /usr/local/mysql/slave-data && chown -R 200 /usr/local/mysql/slave-data mkdir -p /usr/local/mysql/slave-etc && chown -R 200 /usr/local/mysql/slave-etc docker run -tid \ --name mysql-slave \ --privileged=true \ -v /usr/local/mysql/slave-data:/var/lib/mysql \ -v /usr/local/mysql/slave-etc:/etc/mysql/conf.d \ -p 3307:3306 --link mysql-master:master \ -e MYSQL_ROOT_PASSWORD=root \ -d dalomao/mysql-slave:5.7

Nexus3.x

mkdir -p /usr/local/nexus3/data && chown -R 200 /usr/local/nexus3/data
docker run -tid \
--net host \
-p 8081:8081 \
--name nexus \
-e NEXUS_CONTEXT=nexus \
-v /usr/local/nexus3/nexus-data:/nexus-data sonatype/nexus3