GithubHelp home page GithubHelp logo

docker-tips's Introduction

Docker Tips

create image and skip cache

docker build -f docker/Dockerfile123 -t my-image-name --no-cache .

list images

docker images

list all containers

docker ps -a

see containers's output (logs)

docker logs <container_name_or_id>

attach to docker container

 - check container id of running container: docker ps
 - docker exec -it <container_id> /bin/bash

remove all images exept img1, img2 and img3:

docker rmi $(docker images | grep -v 'IMAGE\|img1\|img2\|img3' | awk {'print $3'})

remove all containers exept c1, c2 and c3:

docker rm -f $(docker ps -a | grep -v 'CONTAINER\|c1\|c2\|c3' | awk {'print $1'})

create isolated network:

docker network create --driver bridge isolated_nw

run container:

docker run -d \
   --network=isolated_nw \
   --name=demo-app \
   -p 8000:8000 \
   -e "MONGO_URL=mongodb://mongo/V5-TEST" \
   demo-app

* --name - container name
* -p - port mapping
* -e - ENV
* demo-app - image name

copy file from container to host machine

docker cp container-name:/path/to/file /local/path

copy file from host machine to container

docker cp /local/path/to/file container-name:/path/to/file

cleanup space consumed by unused Docker images, containers, volumes

docker rm $(docker ps -q -f 'status=exited')
docker rmi $(docker images -q -f "dangling=true")
docker volume rm $(docker volume ls -qf dangling=true)

show containers stats (with container names instead of IDs)

docker stats $(docker ps --format={{.Names}})

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.