## Docker Create folder with... - `server.js` ```JS const http = require('http') const server = http.createServer((req, res) => { res.writeHead(200, { 'Content-Type': 'text/plain' }) res.end('Hello World\n') }) server.listen(4000) console.log('Server running at http://localhost:4000') ``` - `package.json` ```JSON { "scripts": { "start": "node server.js" } } ``` - `Dockerfile` ```Dockerfile FROM node:16.6.1 COPY . /src RUN cd /src && npm install EXPOSE 4000 CMD ["node", "/src/server.js"] ``` Build the Docker image: `docker build -t hello-world .` Run the image in a container: `docker run -d -p 4001:4000 hello-world` The -d flag says to run the container in the background (daemon mode). The -p flag maps port 4000 from the container to port 4001 on the docker machine. View your new container: `docker ps -a` Check the logs for your container: `docker logs ` Check the port of the container: `docker port ` Open the app running on the docker machine: open `http://locahost:4001` ## Notes If you make changes to your application, you will need to rebuild your image and restart your container. The docker-machine command controls the virtual machine that is running Docker on your machine. View logs for a docker container: `docker logs ` List the running containers: `docker ps -a` List all local images: `docker images` Remove an image: `docker rmi ` Remove a container: `docker rm `