Monday, May 15, 2017

Docker installation and configration


 yum install epel-release

Install docker in Linux
Yum install docker.io

All check docker service status
/etc/init.d/docker status

All Start docker service
/etc/init.d/docker start

Search available  Docker Image
docker search

Download a Docker Container
docker pull centos

docker two mode for stating

Interactive mode                           docker run -t -i  –name  centos  image name /bin/bash    :-- docker run hello-world

Damain mode 
    docker run -t -d  --name  centos-New name want to create new system  image name  (image name like centos6, ubuntu ) /bin/bash   (shell name)

Docker attached
Docker attach  docker id or name

Check docker  all images
docker images

check running container
 docker ps 

check all background process  running container
 docker ps – a

remove docker image
docker rmi image id

Remove  docker container

docker rm container id

Remove all docker container a single command
docker rm $(docker ps -a -q)



run command without direct login docker container

docker exec container id /Name ls -la /root
docker exec container id /Name mkdir /root/amit
docker exec container id /Name  yum install openssh-server

To start an existing container which is stopped

docker start <container-name/ID>

To stop a running container

docker stop <container-name/ID>

Then to login to the interactive shell of a container
docker exec -it <container-name/ID> /bin/bash

docker rename

docker rename CONTAINER old name  NEW_NAME


 -i  :----represent which container run interactive mode 

 docker build -t sshimage .

Error in http

Redirecting to /bin/systemctl restart  httpd.service
Failed to get D-Bus connection: Operation not permitted

solution :-  /usr/sbin/httpd -k start

Docker container backup
# docker commit -p  78727078a04b  container1
e09f9ac65c8b3095927c14ca0594868f73831bde0800ce66415afeb91aea93cf

Note: - With do above command we have first paused a running container with -p option, made a commit to save the entire snapshot as a docker image with a name container1

we can save it as a tar file and move it freely to any desired docker host system for a deployment:

# docker save -o ~/container1.tar container1

[root@localhost lubos]# ls -l ~/container1.tar
-rw-r--r--. 1 root root 131017216 Jun 14 20:31 /root/container1.tar

Docker container recovery

# docker load -i /root/container1.tar




No comments:

Post a Comment