Using Docker to Build Development Environment
Since playing Docker, I have been deeply fascinated by Docker and have been working on software for so many years. I never expected that software would develop to this stage. Using container isolation technology to isolate various service processes, I am glad to have access to this technology.
Record the process of using Docker to build a development environment for the newly established department. Here is just a rough record of executing commands for later review. I'll give you more details when I have time.
nginx
mkdir -p /apps/nginx/www /apps/nginx/logs /apps/nginx/conf docker pull nginx docker run -p 80:80 --name nginx -v /apps/nginx/www:/www -v /apps/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /apps/nginx/logs:/etc/nginx/logs -d nginx
redis
mkdir -p /apps/redis/data #Write redis default configuration vim /apps/redis/redis.conf docker pull redis docker run -p 6379:6379 -v /apps/redis/data:/data -v /apps/redis/redis.conf:/etc/redis.conf -d --name redis redis redis-server /etc/redis.conf docker exec -it redis redis-cli
mysql
mkdir -p /apps/mysql/data /apps/mysql/logs /apps/mysql/conf docker pull mysql:5.7 docker run -p 3306:3306 --name mysql -v /apps/mysql/conf:/etc/mysql/conf.d -v /apps/mysql/logs:/logs -v /apps/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7 docker exec -it mysql mysql -u root -p123456 grant all privileges on *.* to root@'%' identified by '123456'; flush privileges;
gitlab
mkdir -p /apps/gitlab/config /apps/gitlab/logs /apps/gitlab/data docker pull gitlab/gitlab-ce docker run -d -h gitlab -p 9001:443 -p 80:80 -p 9002:22 --name gitlab --restart always \ -v /apps/gitlab/config:/etc/gitlab \ -v /apps/gitlab/logs:/var/log/gitlab \ -v /apps/gitlab/data:/var/opt/gitlab \ docker.io/gitlab/gitlab-ce
open http://127.0.0.1
nexus3
mkdir -p /apps/nexus chown 200 /apps/nexus docker pull sonatype/nexus3 docker run -d -p 9004:8081 --name nexus --privileged -v /apps/nexus:/nexus-data sonatype/nexus3
Default password: admin/admin123
open http://127.0.0.1:9004
activemq
mkdir -p /apps/activemq/data /apps/activemq/logs /apps/activemq/conf docker pull webcenter/activemq docker run --name='activemq' -d \ -e 'ACTIVEMQ_CONFIG_DEFAULTACCOUNT=false' \ -e 'ACTIVEMQ_ADMIN_LOGIN=admin' -e 'ACTIVEMQ_ADMIN_PASSWORD=admin123' \ -e 'ACTIVEMQ_CONFIG_MINMEMORY=512' -e 'ACTIVEMQ_CONFIG_MAXMEMORY=1536' \ -v /apps/activemq/data:/data \ -v /apps/activemq/logs:/var/log/activemq \ -p 9005:8161 \ -p 9006:61616 \ -p 9007:61613 \ webcenter/activemq
jenkins
mkdir -p /apps/jenkins docker pull jenkins/jenkins:lts docker run -p 9010:8080 -p 9011:50000 -v /apps/jenkins:/var/jenkins_home --name jenkins -d -u root -e JAVA_OPTS=-Duser.timezone=Asia/Shanghai jenkins/jenkins:lts #Adjust time zone docker exec -it jenkins /bin/bash cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime echo 'Asia/Shanghai'>/etc/timezone exit docker restart jenkins
mongodb
mkdir -p /apps/mongodb/data /apps/mongodb/backup docker pull mongo docker run --name mongodb -p 30017:27017 -v /apps/mongodb/data:/data/db -v /apps/mongodb/backup:/data/backup -d mongo --auth docker exec -it mongo mongo admin db.createUser({ user: 'admin', pwd: '123456', roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] }); db.auth("admin","123456"); docker exec mongo sh -c 'exec var=`date +%Y%m%d%H%M` && mongodump -h localhost --port 27017 -u jsmith -p password -d dbname -o /data/backup/$var_test1.dat'