$> diogo --notes-and-thoughts

Docker Getting Started Commands

Sun, 16 Nov 2014

The moment i learned about the docker way of managing containerized applications i was immediately interested in knowing more about it. Just makes much more sense in managing the available machine resources. For now i will just show how to get it running:

Install latest from Docker Installation

# run as root
sudo su

# download debian:testing and run new container
docker run -t -i --net bridge debian:testing /bin/bash

Using docker’s RUN command, we will begin with creating a new container based on the Ubuntu image. We are going to attach a terminal to it using the “-t” flag.

# here we start container and redirect port 80
sudo docker run -i -t -p 80:80 ubuntu /bin/bash

# checkout the list of running containers
docker ps

# or for all container, running and stoped
docker ps -a

# run a stoped container
docker start -a <container_id/container_alias>

# from 1.3 you can enter a running container
docker exec -i -t <container_id/container_alias> /bin/bash

# logout using CTRL-D and container will continue to run

Networking, docker has several modes but the default internal bridge give ip addresses in 172.17.0.1 net. Just do inside the container: ip addr and you will see it.

This entry was tagged as linux docker ubuntu