Skip to content

Instantly share code, notes, and snippets.

@natrod
Last active April 17, 2020 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save natrod/25977493a460afe76d0c6c8f4a6d7f5d to your computer and use it in GitHub Desktop.
Save natrod/25977493a460afe76d0c6c8f4a6d7f5d to your computer and use it in GitHub Desktop.
Basic Docker
<VirtualHost *:80>
ServerName web01-magentodev.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
<Directory "/var/www/html">
Options Indexes FollowSymLinks ExecCGI Includes
Order allow,deny
Allow from all
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
List all running docker instances
docker ps
list all docker containers
docker ps -a
search for a container
docker search {{term}}
download a container
docker pull container_name
{{term}} => Container you are searching for eg: php
start a container
docker start container_name
docker stop container_name
docker run -d -p 80:80 -p 443:443 --name lb -v /home/nathanielrodrigues/lb/src:/var/www/html \
-v /home/nathanielrodrigues/lb/sites-available:/etc/nginx/sites-available \
--link web01:web01-magentodev.com \
--link web02:web02-magentodev.com \
--link web03:web03-magentodev.com nginx
-d Detached
-p port mappings (maps a container port to the parent machines port )
--name gives a name to the container
-v requires 2 args (parent folder path:path inside docker container)
--link links a container to the created container requires 2 args
(container name to be linked: path to be refered to inside the container)
delete a container
docker rm container_name
Get container details
docker inspect container_name
Starting a MySql docker container
docker run --name mysql -v /home/nathanielrodrigues/mage2/mysql:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=password -d -p 3306:3306 mysql
Starting an Apache Docker container
docker run -d --name web01 --link mysql:mysql \
-v /home/nathanielrodrigues/mage2/apache:/var/www/html nimmis/apache-php7
Access shell inside your docker container
docker exec -ti containername /bin/bash
restart apache/nginx inside your docker container without logging in
docker exec -ti container_name service apache2 restart
server {
listen 80;
root /var/www/;
index index.php index.html index.htm;
server_name web01-magentodev.com;
location / {
proxy_pass http://web01-magentodev.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 100M;
client_body_buffer_size 1m;
proxy_intercept_errors on;
proxy_buffering on;
proxy_buffer_size 128k;
proxy_buffers 256 16k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k;
proxy_max_temp_file_size 0;
proxy_read_timeout 300;
proxy_set_header Host $http_host;
}
location ~ /\.ht {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment