Selected topic
Docker Cli
Prefer practical output? Use related tools below while reading.
docker run [options] <image>[:<tag>] [<command>]
<image> is the name of the image to use as a base for the new container.[:<tag>] is optional and specifies a specific tag (version) of the image.[<command>] is optional and specifies a command to run in the new container.-d: Run the container in detached mode, i.e., in the background.-p <port>: Expose a port from the container's network stack to the host machine.-v <volume>: Mount a volume (directory) from the host machine into the container.nginx and we want to run it with the default web server configuration. We can use the following command:
docker run -d --name my-nginx -p 8080:80 nginx
Here:-d runs the container in detached mode.--name my-nginx sets a name for the new container.-p 8080:80 exposes port 8080 on the host machine and maps it to port 80 inside the container (the default web server port for Nginx).nginx is the image to use as a base.http://localhost:8080 in your web browser.If you want to run a specific command inside the container, you can add it after the image name. For example:
docker run -it --rm ubuntu /bin/bash-it options allow for interactive terminal access, and --rm removes the container when it exits.Remember to replace <image> with the actual name of the image you want to use, and adjust the options as needed for your specific use case!