Home  >  Article  >  Operation and Maintenance  >  How to enter commands in docker

How to enter commands in docker

下次还敢
下次还敢Original
2024-04-07 19:09:211374browse

Docker command input method

Input directly

In the terminal of the Docker host, enter the Docker command directly, for example:

<code>docker ps
# 查看正在运行的容器</code>

Docker Compose

Use Docker Compose files to manage multiple containers. Execute in the directory where the Docker Compose file is located:

<code>docker-compose up
# 启动所有定义的容器</code>

Use Docker CLI

Run the command through Docker CLI. Use the docker prefix, for example:

<code>docker run --name my-container ubuntu:22.04</code>

Using the Docker API

Use the Docker API to interact directly with the Docker daemon. Send commands using HTTP requests, for example:

<code>curl -X POST http://localhost:2375/containers/create -d '{"Image": "ubuntu:22.04"}'</code>

Interactive commands

Execute interactive commands in the container. Use the docker exec -it command, for example:

<code>docker exec -it my-container bash</code>

Other methods

  • Docker Desktop: Using Docker Desktop provides a graphical interface for entering commands.
  • Kubernetes: Enter the Docker command through the kubectl command in the Kubernetes cluster.
  • Third-party tools: Use third-party tools such as Portainer or Rancher to manage Docker and enter commands.

The above is the detailed content of How to enter commands in docker. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn