Hi, ubi's here!
Back again, continuing my journey in learning Docker. Today, I want to share some basic Docker commands—though I’m sure there’s still a lot to improve! Here’s what I’ve got so far:
🛠 Basic Docker Commands
- docker pull {image name} → Downloads a specific image from Docker Hub.
- docker images → Lists all downloaded images in Docker.
- docker ps → Shows currently running containers.
- docker ps -a → Displays all containers, including stopped ones.
- docker run -d {image name} → Runs a new container in detached mode.
- docker run {image name/image repository} → A combination of pulling and starting a container.
- docker stop {container id} → Stops a running container.
- docker start {container id} → Starts a stopped container.
- docker run -p 6000:6397 {image name} → Binds the host port (6000) to the container port (6397).
- docker run -d -p 6001:6397 --name {container name} {image name} → Runs a container with a custom name and port binding.
- docker-compose -f {yaml file name} up → Starts multiple containers based on a YAML file.
🐛 Debugging Mode
- docker exec -it {container id} /bin/bash → Opens a terminal inside a container.
- docker exec -it {container name} /bin/bash → Same as above, but using a container’s name instead of ID.
- exit → Closes the terminal session inside the container.
📝 Note: Anything inside {} is like a variable, so you need to replace it based on your needs.
That’s all for now! Will keep adding more as I go. 🚀