Install a new image

docker search <whatever>
docker pull <image>

Run image

  • Runs a new container of image in interactive mode and starts a bash
docker run -i -t <image> bash
  • Start an existing container
docker start -i <container_id>

List installed images

docker images

List running containers

docker ps

Save changes

docker commit <container_id> <image_name>

Export images

docker save <image> > <archive_file>
docker load -i <archive_file>

Update images

  • Only one
docker pull <image>
  • All images
docker images | awk '{print $1}' | xargs -L1 docker pull

Port forward

  • Starts in daemon mode and forwards container port 80 to host port 8888 but only on loopback interface
docker run -d -p <image>
  • Automatically forward all ports
docker run -P <image>

Set fixed IP for container

docker run --ip=<container_ip> --default-gateway=<gw_ip>

Get IP of container

docker inspect <container_id> | grep IPAddress

Share directory between host and container

  • Via Dockerfile
VOLUME        ["/var/volume1", "/var/volume2"]
  • Via command-line
-v /path/on/host:/path/in/container

Allow docker container to access DISPLAY

xhost +local:docker

Display CPU / RAM usage of container

docker stats <container_id>

Get STDOUT / STDERR from container

docker log <container_id>

Get a shell on a running container

Example docker file

# base image is latest official redhat rhel7
from rhel7:latest

# Update the system
RUN yum update -y

# Install web server
RUN yum install -y httpd

# Copy files to image
#COPY ./public-html/ /usr/local/apache2/htdocs/
#COPY ./my-httpd.conf /usr/local/apache2/conf/httpd.conf

# Start the service
ENTRYPOINT ["/usr/sbin/httpd"]


  • Couldn’t create Tag store: unexpected end of JSON input
rm /var/lib/docker/repositories