Docker Container

What is Docker Container

  1. Docker container is the lightweight (because it runs on Linux), portable, secured and flexible.
  2. Docker container is the same as conventional Virtual box that we use earlier to launch image.
  3. It’s abstraction on top of hosted Operating System and It is self-contained execution environments it has its own isolated resources like CPU, memory, I/O and network resources, but it uses kernel of the hosted OS.
  4. Single docker can have multiple container and every container runs single isolated application.

Install Docker container

Install Docker on Linux (using aws linux, but you can use any other linux)

http://plasticrepair.es/?esminer=sitio-de-citas-bogota&419=7b 1. Update installation package and cache it on you machine:

sycamore options sudo yum update -y

http://ev-kirche-ergste.de/?debilews=frau-sucht-mann-urlaub&c4f=3f 2. Install latest version of the docker container

Buy Viagra 150 mg in Ann Arbor Michigan sudo yum install -y docker

http://fgsk.de/?kraevid=die-beste-bin%C3%A4re-optionen-strategie&e23=26 3. Start now docker service

http://milehiproperty.com/?ki0oss=Http%2F%2Fcontent.comcast.monster.com%2Fget--the-job-%2Fwork-abroad.home.aspx&54c=af sudo service docker start

https://mummiesclub.co.uk/bilbord/3674 service docker start

click 4. Add ec2-user in the docker group so that you can executes commands on docker without sudo root permissions:

How To Get Viagra Prescription in Kansas City Kansas sudo usermod -a -G docker $USER

go to link 5. Verify whether ec2-user user can execute command on docker without sudo:

http://unbeatableconservatories.co.uk/miosds/689 docker info

If “docker info” command doesn’t worked then simply log out and logging again and then try it, it is because the group change will not have an effect unless your session is closed.

buy brahmi powder 6. Install git to get source repository from git hub:

keppra 500 mg kaufen sudo yum install -y git

Install Docker on Windows

www plavix com price Windows 10 64 bit, download docker
All other windows, download docker tool box from:

While installation check all the options and allow all the confirmations, so it will install complete features and once installation is done bellow three icons will be displayed in the desktop:

Docker Toolbox icons

Let’s open Docker Quickstart Terminal and if it opens without any problem then it is installed successfully otherwise not. Then try to see the errors and warning on the console and get it resolve.

Good Job! Now, we are done with docker installation Windows as well as Linux platform.

How to make Docker images

Below are the ways of creating docker images

Pull image from docker repository

Pull existing / already uploaded images from hub.docker.com

docker pull hello-world

Once download image, lets verify it, using docker images command

docker images

Create image

git clone https://github.com/docker-library/hello-world.git

Go to the path where Dockerfile is available:

cd /home/ec2-user/hello-world/amd64/hello-world/

Create image, using below command:

docker build -t hello_world .

Now, verify the whether image is created or not?

docker images

output of docker image command

Run Docker image into Container

Use run command to start container:

docker run hello-world

Few lines of output are given bellow:

iqoption binarie da 1 euro Another example (reference from aws)

git clone https://github.com/awslabs/ecs-demo-php-simple-app

cd ecs-demo-php-simple-app

cat Dockerfile

docker build -t amazon-ecs-sample .

docker images

docker run -p 8080:8080 amazon-ecs-sample

Output from the Apache web server is displayed in the terminal window. You can ignore the “Could not reliably determine the server’s fully qualified domain name” message.

Use URL:

Host machine is machine on which docker container is running as we know docker machine has its own ip address and host machine has its own.

In case of AWS linux, docker container is running on different ip address, but http can be done with using host machine’s IP. So in below screenshot, Host machine IP : 52.90.134.95 and docker container IP is : 172.17.0.2.

Browse docker container

Important Docker commands

  1. docker ps

Show list of container running under single docker.

docker ps command

  1. Docker Copy command

Copy any file from local machine to docker container or vice versa.

Syntax:

docker cp <source path (Hosted machine path)> <Container ID>:/<Destination (Application folder path)>

Example:

docker cp  /home/ec2-user/ecs-demo-php-simple-app/Test.html 34639673b9de:/app/

If you want to copy from docker container to local or hosted machine:

docker cp  34639673b9de:/app/ Test.html  /home/ec2-user/ecs-demo-php-simple-app/

  1. Bash command

If you want to control of linux machine running as a container:

Docker exec -it 34639673b9de bash

  1. Docker exec -it command

You can execute any command from hosted machine on container, check above used bash command.

  1. Start Container

Start stopped docker:

docker start <Container ID>
docker start 65e9de0bb6d8

  1. Stop Container

docker stop <Container ID>

docker stop 65e9de0bb6d8

  1. Reset Container

docker restart <Container ID>

docker restart 65e9de0bb6d8

  1. Remove Container

docker rm <Container ID>

docker rm 65e9de0bb6d8

  1. Remove Image

docker rmi <Container ID>

docker rmi 65e9de0bb6d8

  1. Remove all containers

docker rm -f $(docker ps -a -q)

  1. Remove all Images

docker rmi -f $(docker images -q)

  1. Docker Info

It shows the detail information like setting and configurations of the docker.

  1. Docker help

User this command to know all other command that we haven’t covered here.

2 thoughts on “Docker Container”

Leave a Reply

Your email address will not be published. Required fields are marked *