nginx is a docker image where you can run a local website. I have post regarding Docker, in case you need them.
What is a container ?
A container is consisting of copy of Docker Image and an app. You can create as many containers and start/stop/remove them and link them together. Lets create a nginx server.
Run the following code in case don’t have the nginx docker image in your computer.
docker pull nginx //download the image
docker images //list images
Crate a container
Let’s create container and run a sample web app
docker run --name myapp -t latest -d -p 8080:80 nginx:latest
This will run an nginx app on the local host port 8080 which is mapped to 80. To list all containers you can use either on of the command
Go to the browser and try http:///localhost:8080
Other commands
docker ps // list of containers
docker ps -a //stopped containers
docker container ls // list of containers
You can use the id/name to stop/start/remove the container.
docker stop 6ec62466d248 //stop container with id
docker start 6ec62466d248 //start container with id
docker rm 6ec62466d248 //remove the container with id
Wanna remove an image ? use docker rmi <image-id>
Other Docker posts you may interested in
- How to use MSSQL Server on ARM based Mac. - How to use MSSQL Server on ARM based Mac M1,M2
- Access Docker MSSQL Container from Parallel (Mac Mini M2) - How to access Docker Contained DB from Parallel.
- Mac Mini M2 for Windows Developers - Moving from Windows to Mac
- Deploy golang API in Digital Ocean using docker container - How deploy golang API with docker container
- How to Containerize Golang app with Docker - How to containerize Golang app using Docker
- How to create a strapi project with Docker on Windows - How to create a strapi project with Docker in Windows
- Docker-compose for projects - How use docker-compose to run MySQL database base for development
- Create a docker image of Node-Express API – Part II - How to build Node-Express project Docker Image using Node base image
- Create a docker image of Node-Express API – Part I - How to build Node-Express project Docker Image.
- Howto to stop all containers at once in docker - How to stop all containers in docker