Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rks-031/docker-test
https://github.com/rks-031/docker-test
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/rks-031/docker-test
- Owner: rks-031
- Created: 2024-01-21T18:45:19.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2024-01-22T08:16:57.000Z (10 months ago)
- Last Synced: 2024-01-22T22:54:15.843Z (10 months ago)
- Language: Pug
- Size: 1.72 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# pulling nginx image
docker pull nginx
# view the images
docker images
# running containers
docker run nginx: latest (this is in the format: docker run image_name: tag_name) {processes hang}
# list of all running containers
1. docker container ls
2. docker ps# running container in detach mode
docker run -d nginx:latest
# stop container
docker stop container_id
or
docker stop vibrant_liskov# exposing ports
docker run -d -p 8080:80 nginx:latest
{0.0.0.0:8080->80/tcp}
{Baiscally we are mapping the host port 8080 to container port 80}
`Now open any browser and write localhost:8080 as the url`
![Broswer Screenshot localost:8080](image.png)# exposing multiple ports
docker run -d -p 3000:80 -p 8080:80 nginx:latest
# managing containers
docker stop vibrant_liskov
or
docker start vibrant_liskov# docker ps options
docker ps --help
# forcefully remove a container before stopping it
docker rm -f $(docker ps -aq)
# naming a container
docker run --name website -d -p 3000:80 -p 8080:80 nginx:latest
# formatting the way in which dtails of container should appear
docker ps --format="ID\t{{.ID}}\nNAME\t{{.Names}}\nIMAGE\t{{.Image}}\nPORTS\t{{.Ports}}\nCOMMAND\t{{.Command}}\nCREATED\t{{.CreatedAt}}\nSTATUS\t{{.Status}}\n"
# giving the format a name
$env:FORMAT = "ID\t{{.ID}}\nNAME\t{{.Names}}\nIMAGE\t{{.Image}}\nPORTS\t{{.Ports}}\nCOMMAND\t{{.Command}}\nCREATED\t{{.CreatedAt}}\nSTATUS\t{{.Status}}\n"
docker ps --format $env:FORMAT# Volumes
Allows sharing of data. Files or Folders.
Between Host and containers.
Between containers.![Alt text](image-1.png)
# Volume Between Host and Container
![Alt text](image-2.png)
cd `path to directory`
docker run --name website -v $(pwd) -d -p 8080:80 nginx
docker run --name website -v ${PWD}:/usr/share/nginx/html:ro -d -p 8080:80 nginx
`Format`: docker run --name some-nginx -v /some/content:/usr/share/nginx/html:ro -d nginx# Execute the container in interactive mode
docker run --name website -v /some/content:/usr/share/nginx/html -d nginx
docker exec -it website bash
root@9b19f7d00015:/# cd /usr/share/nginx/html/ ....{This is just an exampe}# Volume Between Containers
docker run --name website-copy --volumes-from website -d -p 8081:80 nginx
`To check run`: docker ps --format $env:FORMAT