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:

  1. Get public DNS from https://eu-west-2.console.aws.amazon.com/ec2/v2/home?region=eu-west-2#Instances

  2.  ssh -i path/to.pem [email protected]
    
  3.  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
    

Explanation of docker container run options

  • -v /var/run/docker.sock:/var/run/docker.sock
  • --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.
  • --publish x:y
    • Publishes a container port to a host machine port.
    • The first number x represents the port on the host while the last y represents the container’s port.