2. Run Commands To Get Your Container Image
Docker containers run from images. Open a command prompt or PowerShell console and type docker run -it alpine sh. This command invokes Docker and runs a command (sh) inside a container (alpine). You will not have the alpine image available locally; Docker will automatically download the image from the Docker Hub, a public repository of Docker container images. Once the image downloads, Docker will run the command sh inside the container, which in this case is a Bash shell. Since the -it switch was used, Docker will interactively run the command, leaving the Bash shell open for other commands.
MORE FROM FEDTECH: Find out how your agency can effectively implement DevOps.
3. Stop the Container via a Command
If you have one or more containers running, you can stop them using the docker stop command providing the name of the container. If, for example, you have a container called alpine running in the background, you would stop this container by running docker stop alpine. Once stopped, be sure to confirm the container is stopped by running docker ps to ensure no containers are still running.
4. Remove Containers That Have a Specific ID
Once you’re done with a container, you can remove it from your computer by running the docker container rm command. The rm command removes any container matching a specific ID. If, for example, you had an image with an ID of 837d262be033, you would remove this container by running docker container rm 837d262be033.