Categories
Uncategorized

docker

List images:
docker images

check running containers
docker ps 

check last running container
docker ps -l

change from table to vertical display, first copy/paste the following in the command line
export FORMAT=”ID\t{{.ID}}\nNAME\t{{.Names}}\nIMAGE\t{{.Image}}\nCOMMAND\t{{.Command}}\nCREATED\t{{.CreatedAt}}\nSTATUS\t{{.Status}}\nPORTS\t{{.Ports}}\n”

 Now you can use
docker ps -l –format=”$FORMAT”

Docker commit command: make images out of a container,
First, run a container, docker run -ti ubuntu bash
exit
check latest container, docker ps -l –format=”$FORMAT”
ID 597ff54633b9
NAME agitated_elion
IMAGE ubuntu
COMMAND “bash”
CREATED 2017-06-08 09:48:29 -0400 EDT
STATUS Exited (0) 2 minutes ago
PORTS

docker commit nameofImage neimagename
docker commit agigated_elion copyofUbuntu

run container and delete it when it exits
docker run –rm –ti ubuntu sleep 10

Run a few more things
docker run -rm –ti ubuntu bash -c “sleep 5; echo  returning done sleeping” 

Leaving a running container i.e detached
docker run -d -ti ubuntu bash
docker ps -l –format=”$FORMAT”
ID 4b2feb75ca6b
NAME thirsty_liskov
IMAGE ubuntu
COMMAND “bash”
CREATED 2017-06-08 09:59:39 -0400 EDT
STATUS Up 8 seconds
PORTS

Attach running container,
docker attach thirsty_liskov
If you want to exit and keep it running
Press Ctrl + P and Ctrl+q, this detaches it but leaves it running

execute a new process in a running container,
docker exec thirsty_liskov bash

Kill and remove containers
docker  kill containerName
docker rm containerName

NETWORKING