DevOps - London-Vegan-Coders/LVC-Website GitHub Wiki
Starting the Jenkins docker container
Jenkins is run 24/7 as a service on an EC2 instance so it should seldom be manually started.
However, if you really need to do so:
-
Get public DNS from https://eu-west-2.console.aws.amazon.com/ec2/v2/home?region=eu-west-2#Instances
-
ssh -i path/to.pem [email protected]
-
docker container run \ -v /var/run/docker.sock:/var/run/docker.sock \ --name jenkins-blueocean \ --restart always \ --detach \ --network jenkins \ --publish 8080:8080 \ --publish 50000:50000 \ jenkinsci/blueocean
docker container run
options
Explanation of -v /var/run/docker.sock:/var/run/docker.sock
- Mounts the docker socket on the host to the Jenkins container, allowing it to create sibling containers instead of child containers (aka 'Docker in Docker')
- See https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/
--name jenkins-blueocean
- Sets the Docker container name
--restart always
- Always restart the container if it stops. If it is manually stopped, it is restarted only when Docker daemon restarts or the container itself is manually restarted.
- If you manually stop a container, its restart policy is ignored until the Docker daemon restarts or the container is manually restarted. This is another attempt to prevent a restart loop.
--detach
- Runs the container in the background so the running Docker log is not output in the terminal window.
--network jenkins
- Connects the container to a network (already created earlier) named
jenkins
. - Used for communication between containers.
- Connects the container to a network (already created earlier) named
--publish x:y
- Publishes a container port to a host machine port.
- The first number
x
represents the port on the host while the lasty
represents the container’s port.