Skip to content

Instantly share code, notes, and snippets.

@nguyendangminh
Last active November 9, 2015 02:20
Show Gist options
  • Save nguyendangminh/ff32cf3de5194bbc8f6d to your computer and use it in GitHub Desktop.
Save nguyendangminh/ff32cf3de5194bbc8f6d to your computer and use it in GitHub Desktop.
Docker cookbook
# Installation
$ wget -qO- https://get.docker.com/ | sh
# Some useful commands
$ docker pull ubuntu:latest
$ docker images
$ docker ps
$ docker ps -a
$ docker run -it ubuntu:latest /bin/bash
$ docker run -it --name="my_docker_image" ubuntu:latest /bin/bash
$ docker commit -m "message" <image_name>
$ docker tag <image_id> <new_repos_name>
$ docker run -it -p 5000:5000 <repository>:<tag> /bin/bash
$ docker run -it -p 5000:5000 -v /host_dir:/container_dir <repository>:<tag> /bin/bash # mount
$ docker kill <docker_id> # the same as pausing
$ docker rm <docker_id>
$ docker rm $(docker ps -aq) # remove all stopped containers
# Docker hub
$ docker login
$ docker search ubuntu
$ docker pull minhnd/ubuntu
$ docker tag sample_repos minhnd/sample_repos
$ docker push minhnd/sample_repos:latest
#
# Simple dockerfile
#
FROM ubuntu:latest
MAINTAINER MinhND "[email protected]"
RUN apt-get update
RUN apt-get install python python-pip wget
RUN pip install Flask
ADD hello.py /home/hello.py
WORKDIR /home
# Then run the following command for build new image
# $ docker build -t "flaskr:dockerfile" .
# $ docker run -p 5000:5000 flaskr:dockerfile python hello.py
Error:
Post http:///var/run/docker.sock/v1.19/images/create?fromImage=<removed>: dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?
Solution:
Start the Docker service: $ sudo service docker start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment