What are the commonly used commands for managing Docker containers?
Here are some commonly used Docker container management commands:
- Create a container: docker run
- docker run -itd –name mycontainer ubuntu:latest // Start a new container named “mycontainer” based on the latest Ubuntu image.
- Start container: docker start
- begin mycontainer using docker
- Stop the container: docker stop
- docker command to stop the container named mycontainer
- Restart container: docker restart
- restart mycontainer using docker
- Remove container: docker rm
- remove mycontainer using docker
- View the list of containers: docker ps
- Show all running Docker containers.
- View all container lists, including stopped ones: docker ps -a
- Show all containers, including stopped ones
- Access a running container: docker exec
- Run the bash command inside the container named mycontainer with interactive mode.
- View the container logs: docker logs
- View the logs for mycontainer in Docker.
- View detailed information about the container: docker inspect
- Show me information about mycontainer using the docker inspect command.
- Pause the container: docker pause
- pause my container in Docker
- Resume the paused container: docker unpause
- docker resume mycontainer
- Export container: docker export
- Export the ‘mycontainer’ Docker container and save it as ‘mycontainer.tar’.
- Import container: docker import
- Bring in the container from the mycontainer.tar file using docker import.
- Copy files into a container: docker cp
- Copy the file from the specified path to the “mycontainer” container at the specified destination.
These commands can assist you in managing and operating Docker containers.