less than 1 minute read

  1. Check docker version
        docker version
    
  2. Check for existing docker images
        docker images
    
  3. Copy new image onto your “docker host”
        docker pull <image-name>
    
  4. Start a container from the pulled image
        docker run --name <container-name> -d -p 8080:80 <image-name>
    

    -d to start container in background -p 8080:80 Map port 80 inside container with port 8080 inside docker host

  5. Check which containers are running
        docker ps
    
  6. Execute a command inside the container
        docker exec -it <container-name bash
    

    Here we can run a limited set of linux command only as most containers only ship with essential apps and tools to keep them small.

  7. Exit from container shell
       exit
    
  8. Delete the container and image(cleanup)
        docker stop <container-name>
        docker ps -a
        docker rm <container-name>
        docker ps -a
    

    The -a option of the ps command shows the container entry after stopping it. The same entry disappears once you remove it using the docker rm command.

This is a typical sequence of commands executed in a docker container lifecycle from an operational engineer’s perspective

Updated:

💡 Knowledge grows when shared.

If this helped you, pass it on to someone who might benefit.