Last active
July 30, 2020 15:29
-
-
Save mariorez/1e428419393697f79bbe 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 | |
## Get container ID | |
alias dl='docker ps -l -q' | |
## Get container IP | |
docker inspect --format='{{ .NetworkSettings.IPAddress }}' `dl` | |
docker inspect `dl` | grep IPAddress | cut -d '"' -f 4 | |
## Detach the tty without exiting the shell, use the escape sequence: | |
Ctrl-p + Ctrl-q | |
## Remove Containers and Images | |
docker stop $(docker ps -a -q) | |
docker rm $(docker ps -a -q) | |
docker rmi $(docker images -q) | |
# DOWNLOAD an Linux image | |
docker pull ubuntu | |
docker pull ubuntu:14.04 | |
docker pull debian:wheezy | |
# LIST all images | |
docker images | |
# START container | |
docker run -i -t ubuntu:13.04 /bin/bash | |
# GET container ID | |
docker ps | |
# COMMIT container modifications --- | containerID | repository name | |
docker commit -m "Optional comments" b3f5e7de5ad4 ubuntu_1304_lemp | |
# SAVE in remote Repository | |
docker login | |
docker commit $CONTAINER_ID mariorez/repo_name | |
docker push mariorez/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 -it -p 80:80 ubuntu_1304_lemp /bin/bash | |
# SHARING directories - options rw | ro (read/write | read/only) | |
docker run -it -p 80:80 -v /home/user/project:/var/www/project:rw user/image-name /bin/bash | |
# Remove (--rm) container on exit | |
docker run --rm -it -p 80 -v /home/user/project:/var/www/project --name my-container user/image-name /bin/bash | |
# DNS-Masq | |
## http://docs.docker.io/installation/ubuntulinux/#docker-and-local-dns-server-warnings | |
docker run -it -p 80:80 --dns 127.0.0.1 -v /home/user/project:/var/www/project:rw kanui_debian_squeeze:latest /bin/bash |
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
# Utils Packages (run without "--dns" option) | |
apt-get install whiptail nano mlocate net-tools wget curl procps | |
# Create Custom Domians (docker doesn't provide the "hosts" file) | |
## DNS-Masq installation and Config (run without "--dns" option) | |
## http://docs.docker.io/installation/ubuntulinux/#docker-and-local-dns-server-warnings | |
apt-get install dnsmasq | |
## add custom values in 'dnsmasq' configuration directory | |
nano /etc/dnsmasq.d/custom.conf | |
address=/dev/127.0.0.1 #(ex: ping google.dev) | |
listen-address=127.0.0.1 | |
user=root | |
no-resolv | |
server=8.8.8.8 (nameserver do google) | |
## restart dnsmasq service | |
service dnsmasq restart | |
## Restart docker container witth "--dns" option (see DNS-Masq) | |
# Set Timezone | |
dpkg-reconfigure tzdata |
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
docker run -d -v ~/volumes/mariadb:/var/lib/mysql --env MYSQL_ROOT_PASSWORD=root --env TERM=linux --name project-db mariadb:latest |
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
# inside container create a user with same UID as your | |
useradd -u 1000 docker | |
# Update /etc/nginx/nginx.conf | |
user docker; | |
# Update /etc/php5/fpm/pool.d/www.conf | |
user = docker | |
group = docker |
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
# https://www.rabbitmq.com/access-control.html | |
# https://www.rabbitmq.com/configure.html#configuration-file | |
# Enable remote access using "guest" user | |
# Add to file /etc/rabbitmq/rabbitmq.config | |
[{rabbit, [{loopback_users, []}]}]. |
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
# http://www.johnmcostaiii.net/2013/installing-redis-on-docker/ | |
docker run -i -t -p 6379 redis_service:latest /bin/bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment