docker review basic commands
play

Docker Review Basic Commands docker image ls # list images - PowerPoint PPT Presentation

Docker Review Basic Commands docker image ls # list images currently present locally docker container ls # list running containers docker run <image_name> # run an image as a container docker exec <container> <command> # run a


  1. Docker Review

  2. Basic Commands docker image ls # list images currently present locally docker container ls # list running containers docker run <image_name> # run an image as a container docker exec <container> <command> # run a command in an existing container -it is useful for running something interactive (e.g. /bin/bash) docker build <dir> # compile an image Use -t <name> to assign a name to the image

  3. Making Docker Images Core of specifying an image is the Dockerfile which gives: The base image (FROM) Commands to install software, etc. (RUN) Files to be copied into the image (COPY) Environment variables to set (ENV) The program to be run when the container starts (CMD)

  4. Dockerfile Example # Use an official Python runtime as a parent image FROM python:2.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"]

  5. Image Registries In practice this means hub.docker.com Name scheme is username/repository:tag 'repository' basically means name (has nothing to do with SCM) Username is omitted for official images (e.g. python:2.7-slim) Given an account on a registry, one can docker login # to associate with the account docker tag image username/repository:tag # to create an alias docker push username/repository:tag # to upload the image

  6. Higher Level Organization Docker-Compose - Used to construct 'services' with load balancing and replication, can specify resource limits Swarms/Swarm Clusters - Clusters of machines running docker, used for distributed services Stacks - Collections of co-operating services These features are all largely redundant when using Kubernetes, which is also designed to do these types of organizational tasks

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend