Archive for the ‘docker’ Category

Enable network communication between different docker containers

If we have 2 different docker networks, host from docker-compose network – 172.15.0.5 and second host is through docker start 172.16.0.2 mybash# iptables -L -n | grep DOCKER-ISOLATION DOCKER-ISOLATION-STAGE-1 all — 0.0.0.0/0 0.0.0.0/0 iptables –flush DOCKER-ISOLATION-STAGE-1 After this command containers from 172.15.0.5 can communicate with 172.16.0.2

Docker commiting custom container changes to docker repo

When you login inside docker container and modify it you might want to save the changes Do the following: docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 3c467f494520 c9de8ac964a9 "/bin/bash" 31 minutes ago Up 31 minutes 0.0.0.0:81->80/tcp, 0.0.0.0:444->443/tcp mycontainer Get container name and commit the changes docker commit 3c467f494520 myusername/mydockerimage:latest Push it to […]

Docker push custom image to hub

docker tag mydockerimage myusername/mydockerimage:tagname or docker tag mydockerimage myusername/mydockerimage (if no tagname specified it will assign default one called "latest")   docker login -u myusername (it asks for a password)   docker push myusername/mydockerimage

Docker how-to add extra port to current container

$ docker run -d -t -p 81:80 -v /home/imran/Projects/tmptmp:/var/www/html –name mycontainer ubuntu:latest /bin/bash $ docker stop mycontainer $ docker commit mycontainer mydockerimage $ docker rm mycontainer $ docker run -d -t -p 81:80 -p 444:443 -v /home/imran/Projects/tmptmp:/var/www/html –name mycontainer myusername/mydockerimage:latest /bin/bash

Docker run new container

1. Run docker bash in server mode for latest ubuntu image, with port proxying external 80 to internal 3128, under name myhub, passing through external folder /home/imran docker run -d -t -p 81:3128 -v /home/imran/Projects:/home –name mycontainer ubuntu:latest /bin/bash Output: CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES eea3ed22b802 ubuntu:latest "/bin/bash" 6 seconds ago Up […]

Docker Basic Instructions

Docker Image – Read only layer Docker Container – Read/Write layer 1. Run docker bash in interactive mode for latest ubuntu image docker run -i -t ubuntu:latest /bin/bash 2. Run docker bash in server mode for latest ubuntu image docker run -d -t ubuntu:latest /bin/bash 3. Check running containers docker ps Output: CONTAINER ID IMAGE […]

Benefits of running web app inside docker

Your server itself will not have a big stack installed, like LAMP: all your server needs to know is how to run docker containers. If you deploy an app with a vulnerability and hackers gain root, they will only have root inside a single docker container, and can’t get at your host system. If you […]