Skip to content

Instantly share code, notes, and snippets.

@junaidulqayyumqureshi
Created April 13, 2020 06:46
Show Gist options
  • Save junaidulqayyumqureshi/6da6c010a50677f44af3b4622a2172ea to your computer and use it in GitHub Desktop.
Save junaidulqayyumqureshi/6da6c010a50677f44af3b4622a2172ea to your computer and use it in GitHub Desktop.
Docker
@junaidulqayyumqureshi
Copy link
Author

junaidulqayyumqureshi commented Apr 13, 2020

Source
https://www.youtube.com/watch?v=Kyx2PsuwomE

Installing Nginx

docker run -it -p 3031:80 nginx
3031:80 means that 3031 port which is on this system, map it to port on which service will listen, which is 80

Installing Apache Httpd

docker pull httpd
OR
docker run -d -p 3032:80 --name apacheserver httpd

Installing MySQL

docker run -d -p 3306:3306 --name mySql-db --env MYSQL_ROOT_PASSWORD=123456 mysql
Environment variables i.e. MYSQL_ROOT_PASSWORD can be seen in https://hub.docker.com/_/mysql on docker hub

Bind Mount

docker run -d -p 3031:80 -v D:\Tutorials\Docker\website:/usr/share/nginx/html --name nginx-website nginx
Source
https://www.youtube.com/watch?time_continue=209&v=jTeDNXLFYjE&feature=emb_logo

After the path is linked, create a new index.html file, to override the image directory index.html file which is located in /usr/share/nginx/html

Dockerfile

FROM nginx:latest
WORKDIR /usr/share/nginx/html
COPY . .

Build docker image

docker image build -t hublogin/imagename [path-to-dockerfile]
ie. docker image build -t juniallomate/nginx-website .

Push image to your repository on hub.docker
docker push juniallomate/nginx-website

In case of Access Denied Error
docker login

@junaidulqayyumqureshi
Copy link
Author

Source
https://www.youtube.com/watch?v=bDB4IfJ31HY

Search for image from CLI

docker search --filter=stars=680 mysql
WHERE --filter-starts means only those entries which have n starts or more

@junaidulqayyumqureshi
Copy link
Author

Source
https://www.youtube.com/watch?v=HUpIoF_conA

Docker Compose

Tool for defining multi-container structured docker

Check docker version

docker-compose -v
Filename: docker-compose.yml

@junaidulqayyumqureshi
Copy link
Author

junaidulqayyumqureshi commented Apr 13, 2020

Bash into nginx:
docker exec -it container_name /bin/bash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment