SelfHostCorner

perronedotdev
perronedotdev

Posted on • Originally published at perrone.dev on

Docker Commands

Here are some of the basic Docker commands, syntax and what they are used for. We will go into depth concerning options and arguments in a separate article.


Show the current version of docker that you are running:

docker - version
Enter fullscreen mode Exit fullscreen mode

docker -version [OPTIONS]

Pull an image from a repository:

docker pull
Enter fullscreen mode Exit fullscreen mode

docker pull [OPTIONS] NAME[: TAG|@DIGEST]

Create a container based on the specified image:

docker run
Enter fullscreen mode Exit fullscreen mode

docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

List all of your current containers:

docker ls
Enter fullscreen mode Exit fullscreen mode

docker ps [OPTIONS]

Run a command in a currently running container:

docker exec
Enter fullscreen mode Exit fullscreen mode

docker exec [OPTIONS] CONTAINER COMMAND [ARG...]

Start a stopped container:

docker start
Enter fullscreen mode Exit fullscreen mode

docker start [OPTIONS] CONTAINER [CONTAINER...]

Stop a running container:

docker stop
Enter fullscreen mode Exit fullscreen mode

docker stop [OPTIONS] CONTAINER [CONTAINER...]

Restart a running container:

docker restart
Enter fullscreen mode Exit fullscreen mode

docker restart [OPTIONS] CONTAINER [CONTAINER...]

Kill a running container:

docker kill
Enter fullscreen mode Exit fullscreen mode

docker kill [OPTIONS] CONTAINER [CONTAINER...]

Rename a container:

docker rename
Enter fullscreen mode Exit fullscreen mode

docker rename CONTAINER NEW_NAME

💡

More info and commands can be found on the official Docker website.

Top comments (0)