Last active
November 8, 2018 14:54
-
-
Save DastanIqbal/afac592dd6b1639b83057b4c41709b8b to your computer and use it in GitHub Desktop.
This file contains hidden or 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.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04 | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
sudo apt-get update | |
#apt-cache policy docker-ce | |
sudo apt-get install -y docker-ce | |
#sudo systemctl status docker //check docker status | |
sudo usermod -aG docker ${USER} | |
su - ${USER} | |
#id -nG //list user group | |
sudo usermod -aG docker <username> | |
#Install alpine | |
docker search alpine | |
docker pull alpine | |
docker images | |
docker run -it alpine | |
#Setup Nginx https://wiki.alpinelinux.org/wiki/Nginx_with_PHP#Nginx_with_PHP7 | |
#Inside docker | |
apk update | |
apk add nginx | |
adduser -D -g 'www' www | |
mkdir /www | |
chown -R www:www /var/lib/nginx | |
chown -R www:www /www | |
apk openrc | |
rc-service nginx start | |
nginx -t | |
rc-update add nginx default | |
reboot | |
#Install PHP | |
apk add php7-fpm php7-mcrypt php7-soap php7-openssl php7-gmp php7-pdo_odbc php7-json php7-dom php7-pdo php7-zip php7-mysqli php7-sqlite3 php7-apcu php7-pdo_pgsql php7-bcmath php7-gd php7-odbc php7-pdo_mysql php7-pdo_sqlite php7-gettext php7-xmlreader php7-xmlrpc php7-bz2 php7-iconv php7-pdo_dblib php7-curl php7-ctype | |
PHP_FPM_USER="www" | |
PHP_FPM_GROUP="www" | |
PHP_FPM_LISTEN_MODE="0660" | |
PHP_MEMORY_LIMIT="512M" | |
PHP_MAX_UPLOAD="50M" | |
PHP_MAX_FILE_UPLOAD="200" | |
PHP_MAX_POST="100M" | |
PHP_DISPLAY_ERRORS="On" | |
PHP_DISPLAY_STARTUP_ERRORS="On" | |
PHP_ERROR_REPORTING="E_COMPILE_ERROR\|E_RECOVERABLE_ERROR\|E_ERROR\|E_CORE_ERROR" | |
PHP_CGI_FIX_PATHINFO=0 | |
sed -i "s|;listen.owner\s*=\s*nobody|listen.owner = ${PHP_FPM_USER}|g" /etc/php7/php-fpm.conf | |
sed -i "s|;listen.group\s*=\s*nobody|listen.group = ${PHP_FPM_GROUP}|g" /etc/php7/php-fpm.conf | |
sed -i "s|;listen.mode\s*=\s*0660|listen.mode = ${PHP_FPM_LISTEN_MODE}|g" /etc/php7/php-fpm.conf | |
sed -i "s|user\s*=\s*nobody|user = ${PHP_FPM_USER}|g" /etc/php7/php-fpm.conf | |
sed -i "s|group\s*=\s*nobody|group = ${PHP_FPM_GROUP}|g" /etc/php7/php-fpm.conf | |
sed -i "s|;log_level\s*=\s*notice|log_level = notice|g" /etc/php7/php-fpm.conf #uncommenting line | |
sed -i "s|display_errors\s*=\s*Off|display_errors = ${PHP_DISPLAY_ERRORS}|i" /etc/php7/php.ini | |
sed -i "s|display_startup_errors\s*=\s*Off|display_startup_errors = ${PHP_DISPLAY_STARTUP_ERRORS}|i" /etc/php7/php.ini | |
sed -i "s|error_reporting\s*=\s*E_ALL & ~E_DEPRECATED & ~E_STRICT|error_reporting = ${PHP_ERROR_REPORTING}|i" /etc/php7/php.ini | |
sed -i "s|;*memory_limit =.*|memory_limit = ${PHP_MEMORY_LIMIT}|i" /etc/php7/php.ini | |
sed -i "s|;*upload_max_filesize =.*|upload_max_filesize = ${PHP_MAX_UPLOAD}|i" /etc/php7/php.ini | |
sed -i "s|;*max_file_uploads =.*|max_file_uploads = ${PHP_MAX_FILE_UPLOAD}|i" /etc/php7/php.ini | |
sed -i "s|;*post_max_size =.*|post_max_size = ${PHP_MAX_POST}|i" /etc/php7/php.ini | |
sed -i "s|;*cgi.fix_pathinfo=.*|cgi.fix_pathinfo= ${PHP_CGI_FIX_PATHINFO}|i" /etc/php7/php.ini | |
rc-service nginx restart | |
rc-service php-fpm start | |
rc-update add nginx default | |
rc-update add php-fpm default | |
reboot | |
#List Container | |
docker ps -l | |
#Save Progress | |
docker commit containerId alpine-nginx | |
#Check commit | |
docker images | |
#Access container from Host https://www.tecmint.com/install-run-and-delete-applications-inside-docker-containers/ | |
docker run -it -p 81:80 alpine-nginx /bin/sh | |
mkdir -p /run/nginx | |
nginx & | |
php-fpm7 | |
ctrl+q | |
netstat -tlpn | |
#Type ipaddress in browser to access nginx | |
#Run startup script when docker start | |
docker run -it -p 81:80 alpine-nginx /opt/startup.sh | |
#startup.sh could be | |
nginx & | |
php-fpm7 | |
#Test server in browser | |
#Share code or directory between host & directory | |
docker run -v ~/<path>/src:/www -p 81:80 -it alpine-nginx | |
### Remove Docker Images | |
docker rmi <imageId> | |
### Create Tag | |
docker tag bb38976d03cf hubusername/imagename:tagname | |
### Push docker to hub | |
docker push hubusername/imagename | |
### Save Locally | |
docker save imagename > imagename.tar | |
### Load local image | |
docker load --input imagename.tar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment