Coder Social home page Coder Social logo

full-stack-docker's Introduction

full-stack-docker

Docker Terminal Commands

To get new images run:

docker pull image_name_here

List all docker images:

docker images

List running containers:

docker ps

List all containers:

docker ps -a

To create a image:

  • docker build -t image-name path-to-directory-with-dockerfile
docker build -t api_image .

To create a container:

  • --name gives the container its name
  • -p allows you to map a localhost port to the container port
  • -d allows you to run the container detached from the terminal (you can still run commands in the terminall while the container is running)
docker run --name api_container1 -p 8080:8080 -d api_image
  • -v creates a volume. This maps a folder on our computer to a folder in the container allowing it to pick up changes we make. The second -v creates an anonymous volume which maps the node_modules in our container to folder managed by docker. This allows us to delete our node_modules locally and not delete our node_modules in our container.
docker run --name api_container1 -p 8080:8080 -v /Users/vinibjazevich/Code/docker-fullstack/api:/app -v /app/node_modules -d api_image

To stop a container:

docker stop api_container1

To start a existing container:

docker start api_container1

To delete an image:

docker image rm api_image

To delete an container:

docker container rm api_container1

Delete all images, containers, and clear cache:

docker system prune

To run docker compose file (create all docker images referenced and run containers):

docker compose up

To stop and delete containers but keep images:

docker compose down

To delete containers, images, and volumes:

docker compose down --rmi all -v

Docker Basics

Images (blueprints for containers)

Images contain the following:

  • runtime environment
  • application code
  • any dependencies
  • extra configuration (env variables)
  • commands
  • own file system independent from computer

image

Parent images: image

You can get docker images from docker hub: https://hub.docker.com/search?q=

image

When a image is ran a container is made from that image: image image

The app can run the same exact way on every machine because the image kept the exact versions of everything we need. image

Dockerfile (set of instructions to create a docker image)

image

Docker Compose

image

Containers (box to run app with everything it needs)

Containers run independently from any of the processes on your computer:

image

To create a new container you need to run an image: image

Here you can give the container a name, choose its ports, and provide environment variables.

  • The left port is our localhost port and the right port is the container port

image

Helpful Articles

full-stack-docker's People

Contributors

vinibjazevich avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.