GithubHelp home page GithubHelp logo

docker-cheatsheet's Introduction

Cheatsheet for Docker

Docker compose

docker-compose build
docker-compose up -d
docker-compose ps
docker-compose down

Dockerfile

# creator
MANTAINER Matheus Vanzan
LABEL mylabel

# files
COPY
ADD

# user
ENV USER docky
RUN useradd -ms /bin/bash $USER
RUN usermod --password $USER $USER

# python virtualenv
ENV VIRTUAL_ENV=/home/$USER/env
RUN python -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

# no password for sudo
RUN echo "ALL ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/nopass

# workdir
WORKDIR /home/docky

# port
EXPOSE 3000

# last 
ENTRYPOINT

Usage Build

# spec file
docker build -f filename

# spec tag
docker build -t

# complete custom
docker build --rm -f Dockerfile -t username/docker-image:latest .

Usage Checks

# check port
docker port image-hash

Usage Run

# run with name
docker run --name meu-container

# run detached
docker run -d docker-image

# run it
docker run -it docker-image

# run random port
docker run -P docker-image

# run with port
docker run -p 8080:8080 docker-image

# run with env var
docker run -e MYENV=my_value"

# run with working dir (cd)
docker run -w /home/docky/

# run with volume
docker run -v $(pwd)/media:/home/docky/media

# run in network
docker run --network local-network

Bulk remove

# all containers
docker rm -vf $(docker ps -a -q)

# not active containers
docker container prune

# all images
docker rmi -f $(docker images -a -q)

Usage networks

docker network create --driver bridge local-network
docker run --network local-network

docker-cheatsheet's People

Contributors

matheusvanzan 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.