AI Generated Cheatsheets

Docker Cheatsheet

Overview

Docker is a platform for developing, shipping, and running applications in containers.

Installation

Basic Usage

  1. Create a Dockerfile in the root directory of your project.
  2. Define the base image and any additional dependencies or configuration.
  3. Build the Docker image using docker build.
  4. Run the Docker container using docker run.

Dockerfile Syntax

# Use an official Python runtime as a parent image
FROM python:3.7-slim

# Set the working directory to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . /app

# Install any needed packages specified in requirements.txt
RUN pip install --trusted-host pypi.python.org -r requirements.txt

# Make port 80 available to the world outside this container
EXPOSE 80

# Define environment variable
ENV NAME World

# Run app.py when the container launches
CMD ["python", "app.py"]

Commands

Resources