DevOps


JENKINS


Jenkins Installation

To Start Jenkins: java -jar jenkins.war –httpPort=9090

Install Rsync using cygwin
http://www.shaileshsonare.com/blog/c-programming/rsync-on-windows-os/

Rsync command:
rsync -avzh . /var/www/html/jenkinstest/prod/ –delete


Docker Container


How to create docker image


How to create docker image

  1. Create Docker file: Dockerfile
    FROM php:7.0-apache
    COPY src/ /var/www/html
    EXPOSE 80
  2. docker build -t image-filename docker-file-location
    docker build -t hello-world .
  3. sudo docker run -p localpot:imageport image-name
    sudo docker run -p 8989:80 image-name

    To mount with local app with image
    sudo docker run -p 8980:80 -v /var/www/html/localapp/:/var/www/html -i -t php-app

    To copy files from host to docker container
    sudo docker cp ./test.php container:/var/www/html/

    To start existing container
    sudo docker start container


How to export and import image

You will need to save the docker image as a tar file:

docker save -o <path for generated tar file> <image name>

Then copy your image to a new system with regular file transfer tools such as cp or scp. After that you will have to load the image into docker:

docker load -i <path to image tar file>

PS: You may need to sudo all commands.

Ref: Link: https://stackoverflow.com/questions/23935141/how-to-copy-docker-images-from-one-host-to-another-without-via-repository


How to remove container and images

Docker ps -a               # Lists containers (and tells you which images they are spun from)
Docker images              # Lists images  
Docker rm <container_id>   # Removes a container

Docker rmi <image_id>      # Removes an image 
                           # Will fail if there is a running instance of that image i.e. container

Docker rmi -f <image_id>   # Forces removal of image even if it is referenced in multiple repositories, 
                           # i.e. same image id given multiple names/tags 
                           # Will still fail if there is a docker container referencing image

Ref Link: https://stackoverflow.com/questions/33907835/docker-error-cannot-delete-docker-container-conflict-unable-to-remove-reposito