zoukankan      html  css  js  c++  java
  • Docker Engine SDKs and API 的开发2

    Examples using the Docker Engine SDKs and Docker API

    After you install Docker, you can install the Go and Python SDKs and also try out the Docker Engine API.

    Each of these examples show how to perform a given Docker operation using the Go and Python SDKs and the HTTP API using curl.

    Run a container

    This first example shows how to run a container using the Docker API. On the command line, you would use the docker run command, but this is just as easy to do from your own apps too.

    This is the equivalent of typing docker run alpine echo hello world at the command prompt:

    Run a container in the background

    You can also run containers in the background, the equivalent of typing docker run -d bfirsh/reticulate-splines:

    List and manage containers

    You can use the API to list containers that are running, just like using docker ps:

    Stop all running containers

    Now that you know what containers exist, you can perform operations on them. This example stops all running containers.

    Note: Don’t run this on a production server.

    Also, if you are using swarm services, the containers stop, but Docker creates new ones to keep the service running in its configured state.

     

    You can also perform actions on individual containers. This example prints the logs of a container given its ID. You need to modify the code before running it to change the hard-coded ID of the container to print the logs for.

    List all images

    List the images on your Engine, similar to docker image ls:

    Pull an image

    Pull an image, like docker pull:

    Pull an image with authentication

    Pull an image, like docker pull, with authentication:

    Note: Credentials are sent in the clear.

    Docker’s official registries use HTTPS.

    Private registries should also be configured to use HTTPS.

    Commit a container

    Commit a container to create an image from its contents:

  • 相关阅读:
    3月4日毕设进度
    3月3日毕设进度
    3月2日毕设进度
    3月1日毕设进度
    2月29日毕设进度
    2月28日毕设进度
    2月27日毕设进度
    进度报告七 (重大技术需求调研)
    进度报告六-(重大技术需求调研)
    进度报告五 (重大技术需求调研)
  • 原文地址:https://www.cnblogs.com/panpanwelcome/p/9295507.html
Copyright © 2011-2022 走看看