Docker basic command

  • docker pull
sudo docker pull busybox

Pull the Busybox repository from Docker registry to our local system.

  • docker images
sudo docker images

List all images saved on the local system.

  • docker run busybox
sudo docker run busybox

You may find that nothing happens after sending the command.
What is going on?

Well the busybox container has actually been started, and commands are run inside the container.
But we did not issue a command to the container, so it exited.

  • docker ps
sudo docker ps -a

Show your containers currently running, append "-a" to list all containers.

You can found the status of container - "Exited".


Practice more:

sudo docker run busybox echo "2021/08/09"

Here we give the busybox container the command "echo".
As expected, we will get the output.

Because the above experiments are all one-offs, what if we want to interact with the container?

sudo docker run -it busybox sh

Now, you can do lots of things within this container.
[P.s] This container is just a busybox, so its environment cannot do any complicated applications. We will talk more about how to build applications using Linux mirroring.


@ docker for devops series - 1

tags: CY