Home >Operation and Maintenance >Docker >How to enter commands in docker
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
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!