Skip to content

Instantly share code, notes, and snippets.

@licode
Last active November 4, 2018 17:17
Show Gist options
  • Save licode/4b3041d205f3e54fd8817449d3940a52 to your computer and use it in GitHub Desktop.
Save licode/4b3041d205f3e54fd8817449d3940a52 to your computer and use it in GitHub Desktop.
docker images
docker run -i -t docker_name:version
docker run -it -name li docker_name:version # give it a name
# list containers
docker ps
# go back to a running image
docker attach name(or ID)
# stop a container
docker stop name
docker containter stop name
# rm a image
docker rmi -f name
# docker file
# docker file, -> build an image, run to get a container
FROM command: get image from dockerhub
COPY command: in docker file, we can copy file from local folder to image folder
#build based on docker file, at current folder
# build image
docker build -t name . # current folder
docker build -t name -f docker_file
docker build -t hello-world .
# use volume, amount a local directory to container
docker run -v local-folder-path:/var/www/html/ image_name
# list all recent runs
docker ps -a
docker diff run_id # check the difference
# commit change to a image
# take a snap shot of the current version
docker commit run_id new_name
# docker image sharing, push or share docker image
hub.docker.com
# systemctl command, edit at /etc/systemd
sudo systemctl start docker
# or run as server
sudo service docker start
systemctl status docker
systemctl stop docker
# remove all stopped containers, all unused networks, all dangling images and build caches.
docker system prune -f
# auto clean each time
docker run --rm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment