Episode 5. Understanding Docker Images and Containers in Depth

Image vs Containers:

Getting Pre-built Image:


  1. Check available containers locally:
docker ps -a
docker run <image-name>eg. docker run node 
docker ps -a
docker run -it <package name>      // container interactive modeeg. docker run -it node
docker ps -a
FROM node      // Use base image from Docker HubWORKDIR /app   // Paste code insode /app directory of containerCOPY . /app    // first parameter= copy all file from current directory, paste inside container’s /app directoryRUN npm install. // run npm install. (in container)EXPOSE 80.       // Use port 80CMD ["node", "server"]. // Run node server (in container and not image)
docker build .
docker run <image id>eg. docker run 0364ae96bd20f5d9361564e907d9f1f1656fca2d9f2996c0496ca713afdae76
docker ps
docker stop <containers assigned name>eg. docker stop silly_neumann awesome_ardinghelli nifty_lederberg
docker ps
docker -p <localport:dockerport> <container ID>eg. docker run -p 3000:80 20364ae96bd20f5d9361564e907d9f1f1656fca2d9f2996c0496ca713afdae76
docker run abcdefg.    // will work
docker run abc // will also work


Closing Thoughts:



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store