Giter Site home page Giter Site logo

container's Introduction

container

About container, docker, etc.

Docker

Frequently used commands:

# list of images
docker images

# list of all containers
docker ps -a

# pull ubuntu with tag 22.04
docker pull ubuntu:22.04

# run a container from an image.
# run = create + start
# bind local port 5000 to container's port 80 
docker run -d -t -p 5000:80 --name myubuntu1 ubuntu:22.04

# stop a container
docker stop myubuntu1

# start a container
docker start myubuntu1

# bash on the container
docker exec -it myubuntu1 bash

# delete conainer (must be stopped first)
docker rm [hash of the conainer, e.g. from docker ps]

# delete an image
docker rmi [hash of the image, e.g. from docker images]

# construct a new image from the current container
docker commit container1 container2

Dockerfile

Sample dockerfile to create a linux box and run a Flask app. Save this file in the project folder. Add a .dockerignore file to excludes files not needed in the image, similar to .gitignore. This particular file uses the default flask server, and is not recommened for production.

FROM ubuntu:22.04

WORKDIR /app

COPY . .

RUN apt update  && \
    apt install -y wget lsof python3.10 python3-pip python3-venv && \
    apt clean && \
    python3 -m venv .venv && \ 
    . ./.venv/bin/activate && \
    python3 -m pip install --upgrade pip && \
    pip3 install -r requirements.txt && \

CMD ["python3", "-m", "app"]

EXPOSE 80

To build the image:

docker build myimage:mytag .

container's People

Contributors

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