Containers are packages that are within a set of rules. They are composed mainly by a slim OS that is made to execute what the user asked.

Basic Commands

docker run hello-world #Verify the installation

docker container run ubuntu #Initialize Ubuntu based container
docker container run ubuntu echo 'Tst' #Run "echo 'Tst'" before container is finished
docker container ls -a #List all the containeirs in the current machine
docker container ls -l #Check only the last container created

Field Meanings

Create Container Commands

docker container run --name Test alpine
docker container run --rm apline #Remove files after finished
docker container run -d aplpine #Run process in background
docker container create alpine #Create only, do not run

Container Interaction Commands

docker container start || restart [id || name]
docker container pause || unpause
docker container stop
docker container attach # Remove process from background
docker container rm -f # -f is to stop execution
docker container prune # Remove all unused containers

Run Terminal Inside Container

# On Create
docker container run -ti ubuntu

#Later
docker exec -it [imgName] bash || sh

The command above has the -t for terminal and -i indicating that we want physical communication with the image. In this case, the keyboard will do.

To exit the terminal simply type: exit.

There should be a CLI button in Docker Desktop Interface as well for easy connection to the Terminal.