Docker

Docker containers wrap a piece of software in a complete filesystem that contains everything needed to run: code, runtime, system tools, system libraries – anything that can be installed on a server. This guarantees that the software will always run the same, regardless of its environment.

  1. Run a Hello World
$docker run ubuntu /bin/echo 'Hello World'
docker run runs a container.
/bin/echo is the command to run inside the new container.
2. Run an interactive container
$docker run -t -i ubuntu /bin/bash
-t flag assigns a pseudo-tty or terminal inside the new container.
-i flag allows you to make an interactive connection by grabbing the standard input of the container.
/bin/bash launches a Bash shell inside our container.
  1. Start a daemonized Hello world
$docker run -d /bin/sh -c "While true; do echo hello world; sleep 1; done;"
-d flag runs the container in the background (to daemonize it)
The long string is called container ID, it uniquely identifies a container so we can work with it.
Docker automatically generates names for any containers started.
  1. To see what the docker is doing
$ docker logs docker_name
  1. To stop the docker
docker stop docker_name
  1. To remove a docker
$ docker rm acr434w3dmkf

Summary:

  1. docker ps -- list containers
  2. docker logs -- shows the standard output of the container
  3. docker stop -- Stops running contains

  4. To specify the port

$ docker run -d -p 8080:80 ubuntu
  1. Load balance between four application
$docker run -d --name web1 -p 8080:80 tutum/hello-world

results matching ""

    No results matching ""