- Prepare Hellow World application using your technology stack
- Build Dokerfile for it
- Setup Docker repository for images
- Setup Jenkins using docker
- Build your docker image using a Jenkins pipeline
$ docker run container:version
[overvrite CMD with /bin/sh]
$ docker run -ti container:version /bin/sh
[mount volume]
$ docker run -v local_dir:/container_dir/ container:version
[expose ports]
$ docker run p 50000:50000 container:version
[add custom name to container]
$ docker run -n my_name container:version
[clean when container is done]
$ docker run --rm container:version
[daemon]
$ docker run -b container:version
[listing running containers]
$ docker ps $ docker ps -a
$ docker stop container_name $ docker kill container_name
$ docker rm container_name
https://docs.docker.com/engine/reference/commandline/build/
$ docker build -t my-image:latest .
Dockerfile:
FROM RUN COPY/ADD CMD/EXEC
Check: https://hub.docker.com/search?q=&type=image Interesting images: popular applications (nginx, mysql, etc.); linux distros: centos, alpine etc.
docker run -d -v jenkins_home:/var/jenkins_home -p 8080:8080 -p 50000:50000 jenkins/jenkins:lts
https://docs.docker.com/registry/deploying/
$ docker run -d -p 5000:5000 --restart=always --name registry registry:2
check: http://localhost:5000/v2/_catalog
Pushing image to repository:
docker pull ubuntu:16.04 docker tag ubuntu:16.04 localhost:5000/my-ubuntu docker push localhost:5000/my-ubuntu
$ git clone https://github.com/mcj-krs/docker-workshop then check jenkins-with-docker