A, docker-nginx:
docker pull nginx docker run --name nginx -p 80:80 -d nginx mkdir -p /usr/local/docker/nginx/www /usr/local/docker/nginx/conf /usr/local/docker/nginx/logs docker cp ${container-id}:/etc/nginx/nginx.conf /usr/local/docker/nginx/conf docker stop nginx docker rm nginx docker run -d -p 80:80 --name nginx -v /usr/local/docker/nginx/www:/usr/share/nginx/html -v /usr/local/docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /usr/local/docker/nginx/logs:/var/log/nginx nginx
二、docker-redis:
docker pull redis mkdir -p /usr/local/docker/redis/conf /usr/local/docker/redis/data docker run -p 6379:6379 --name redis -v /usr/local/docker/redis/conf:/etc/redis/redis.conf -v /usr/local/docker/redis/data:/data -d redis redis-server /etc/redis/redis.conf --appendonly yes # /usr/local/docker/redis/conf挂载到/etc/redis/redis.conf # /usr/local/docker/redis/data挂载到/data # --appendonly yes 开启持久化
三、docker-jenkins
1. Create a new Dockerfile
under / usr / local / docker / jenkins
touch Dockerfile
vi Dockerfile
2. Add the following:
Jenkins the FROM the USER the root # Clear the source base image set, switched to Tencent cloud jessie source # Tencent need to use a non-cloud environment will tencentyun to aliyun #run echo ''> /etc/apt/sources.list.d/ jessie- backports.list \ # && echo "deb http://mirrors.aliyun.com/debian Jessie main contrib non-as Free"> / etc / APT / sources.list \ # && echo "deb HTTP: // Mirrors. Jessie-the Updates main contrib aliyun.com/debian non-as Free ">> / etc / APT / sources.list \ # && echo" deb http://mirrors.aliyun.com/debian-security Jessie / nON-the Updates main contrib as Free ">> / etc / APT / sources.list # update the source and install the missing packages RUN APT -get APT-GET install update && && -y libltdl7apt-get update ARG dockerGid999 = the RUN echo "Docker: X: $ {} dockerGid: Jenkins" >> / etc / Group # mounted Docker - Compose because the build environment that require the RUN curl -L HTTPS: // github.com/docker/compose/ Releases / downloads / 1.16.1 / Docker-Compose-`uname -s` -o-`uname -m` / usr / local / bin / Docker-Compose the RUN the chmod + X / usr / local / bin / Docker-Compose
3. Build
docker build . -t jenkins
4. Jenkins at startup, you need to create a configuration directory Jenkins, and mount to the next docker in the Jenkins directory
mkdir -p /var/jenkins_home
5. Modify directory permissions (very important!)
chown -R 1000 /var/jenkins_home
6. Run Jenkins
docker run --name jenkins -p 8080:8080 -p 50000:50000 \ -v /var/run/docker.sock:/var/run/docker.sock \ -v $(which docker):/bin/docker \ -v /var/jenkins_home:/var/jenkins_home \ -d jenkins
7. into the container
docker exec -it jenkins /bin/bash
8. Check password
cat /var/jenkins_home/secrets/initialAdminPassword
source:
Rookie Tutorial