By - scmGalaxy.com
You
- Basic Computer Knowledge
- Do not need to be Linux expert
Computer
- 1 -2 Linux Machine (Can be Vms)
> apt-get update
> apt-get install -y docker.io
> service docker.io start
> yum update
> yum install -y docker.io
> systemctl start docker.service
> docker -v
> docker version
> service docker.io status
> systemctl status docker.service
> docker info
> wget -q0- https://get.docker.com/gpg | apt-key add -
> echo deb http://get.docker.com/ubantu docker main > /etc/apt/sources.list.d/docker.list
> apt-get update
> apt-get install lxc-docker
> docker version
> docker run -it ubuntu /bin/bash (as a non-root)[ permission denied]
> cat /etc/group
> sudo gpasswd -a username docker
> cat /etc/group
> docker run -it ubuntu /bin/bash (as a non-root)
> logout
> login username
> docker -v
> netstat -tlp
> service docker stop
> docker -H ipaddress:port -d &
> netstat -tlp
> export DOCKER_HOST="tcp://ipaddress:port" (from another machine)
> docker version
So a running image is a container.
Reference
docker pull -a fedora
Docker info
> docker run -it fedora /bin/bash
> docker images fedora
[ Images are stored under /var/lib/docker/<storage drivers>
> docker run -it ubuntu /bin/bash
> docker images
> docker ps
> docker attach <container_id>
> docker ps -a
Pull the official jenkins image from Docker repository.
> docker pull jenkins
Next, run a container using this image and map data directory from the container to the host; e.g in the example below /var/jenkins_home from the container is mapped to jenkins/ directory from the current path on the host. Jenkins 8080 port is also exposed to the host as 49001.
> docker run -d -p 49001:8080 -v $PWD/jenkins:/var/jenkins_home -t jenkins
Other commands
> docker run -p 8080:8080 jenkins
> docker create -v /var/jenkins_home --name jenkins-dv jenkins
> docker run -d -p 8080:8080 --volumes-from jenkins-dv --name myjenkins jenkins
> http://localhost:8080
> docker run -d -p 8080:8080 --volumes-from jenkins-dv --name myjenkins2 jenkins