Pacific-Design.com

    
Home Index

1. Linux

2. Docker

+ Installation

Linux / Docker /

Docker daemon on CentOS

Docker Administration


# Start Docker Service 
$ service docker start
$ chkconfig docker on

# Download centos or ubuntu image
$ docker pull centos
$ docker pull ubuntu

# Verify centos or ubuntu images
$ docker images centos
$ docker images ubuntu

# Run centos or ubuntu docker
$ docker run -it centos bash
$ docker run -it ubuntu bash

# Detach from container
docker> Ctrl+p + Ctrl+q

# Attach to docker
$ docker attach 73a382e1a43d

# Listing containers
$ docker ps      # Lists only running containers
$ docker ps -a   # Lists all containers

# Commit your container to a new named image
$ docker commit container_id new_name

# List your containers
$ sudo docker images

Manipulation of Images and Containers


# Save image to a file
$ docker save -o /root/kevin1.tar kevin1

# Copy/Load image to a docker
$ docker load -i /root/kevin1.tar

# Remove all stopped containers
$ docker rm $(docker ps -aq)
	$ docker rm $(docker ps -a | grep Exited | awk '{print $1}')
	$ docker ps -a | grep 'weeks ago' | awk '{print $1}' | xargs --no-run-if-empty docker rm



# Start Container
	$ docker start dea95e30f3ea

# Attach into Container
	$ docker attach dea95e30f3ea

# Export Container ID
	$ docker export CONTAINER_ID > my_container.tar

# Import Container ID
	$ docker import my_container.tar