Last active
August 29, 2015 14:05
-
-
Save pvgomes/5c0c35e0d70bbf71ad6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# HINTS | |
## add self to the docker group (run docker without sudo) | |
sudo gpasswd -a myusername docker | |
# Detach the tty without exiting the shell, use the escape sequence Ctrl-p + Ctrl-q | |
# DOWNLOAD an Linux image | |
docker pull ubuntu | |
docker pull ubuntu:14.04 | |
docker pull debian:wheezy | |
# LIST all images | |
docker images | |
# Remove one or more containers | |
docker rm CONTAINER_ID | |
# Remove one or more images | |
docker rmi IMAGE_ID | |
# START container | |
docker run -i -t ubuntu:13.04 /bin/bash | |
# List Runing Containers | |
docker ps | |
# List all containers | |
docker ps -a | |
# COMMIT container modifications --- | containerID | repository name | |
docker commit -m "Optional comments" b3f5e7de5ad4 ubuntu_1304_lemp | |
# Show containerid to last container | |
docker ps -l -q | |
# Show ipadress to container | |
docker inspect CONTAINERID | grep IPAddress | cut -d '"' -f 4 | |
# SAVE in remote Repository | |
docker login | |
docker commit $CONTAINER_ID mariorez/repo_name | |
docker push pvgomes/repo_name | |
# EXPORT container to a filesystem as a tar archive to STDOUT | |
docker export $CONTAINER_ID > latest.tar | |
# IMPORT container | |
## from remote location: | |
docker import http://example.com/exampleimage.tgz | |
## from local file: | |
cat exampleimage.tgz | sudo docker import - exampleimagelocal:new | |
# START the new container with port redirection | |
## -p -> publish a container's port to the host | |
## format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort | |
## (use 'docker port' to see the actual mapping) | |
docker run -i -t -p 80:80 ubuntu_1304_lemp /bin/bash | |
### TAGGING | |
docker tag IMAGEID name:tagname | |
example: | |
docker tag 0f46779145c9 base:5.3 | |
### Creating | |
1º Up onde docker image | |
docker run -i -t ubuntu:14.04 /bin/bash | |
2º Get the containet id | |
docker ps | |
3º commit the container using new repo name | |
docker commit -m "image" 1debfc84f8cf pvgomes/lemp | |
4º listing images | |
docker images | |
5º You did see your image, push this | |
docker push pvgomes/lemp | |
#Expose you container for other machines (in you machine) | |
sudo iptables -t nat -A DOCKER -p tcp --dport 88 -j DNAT --to-destination 172.17.0.2:80 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment