Home>Article>Operation and Maintenance> 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:
docker ps # 查看正在运行的容器
Docker Compose
Use Docker Compose files to manage multiple containers. Execute in the directory where the Docker Compose file is located:
docker-compose up # 启动所有定义的容器
Use Docker CLI
Run the command through Docker CLI. Use thedocker
prefix, for example:
docker run --name my-container ubuntu:22.04
Using the Docker API
Use the Docker API to interact directly with the Docker daemon. Send commands using HTTP requests, for example:
curl -X POST http://localhost:2375/containers/create -d '{"Image": "ubuntu:22.04"}'
Interactive commands
Execute interactive commands in the container. Use thedocker exec -it
command, for example:
docker exec -it my-container bash
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!