<commit_before>
            
   DOCKER   
            



                                             /=+===============================+=\ 
                                            /  :                               :  \  
                                            )==:         DOCKER ENGINE         :==(   
                                            \  :_______________________________:  /    
                                             \=+===============================+=/

VERSION ==>                       #1.12.2

docker deamon:
  - binds to Unix socket:
     - owned by "docker" group if it exists, "root" (avoid) otherwise

Start deaemon:
  - once: sudo service docker start
  - all the time: sudo systemctl enable docker

Memory and swap accouting:
  - must be enabled on the OS: performance impact, but better OS memory management
  - see online doc for how to enable it

IMAGE                             #Stateless filesystem snapshot, with metadata
                                  #IMAGE from Docker Hub.
                                  #Pulled unless cached
                                  #Is either:
                                  #  - IMAGE_ID (can be shortened)
                                  #  - [HOSTNAME/][REPO_USER/]IMAGE_NAME[:TAG]:
                                  #     - def HOSTNAME: registry-1.docker.io
                                  #     - REPO_USER (if push|pull, def: docker): see Docker Hub
                                  #     - IMAGE_NAME: [[:alnum:]._-]
                                  #     - def TAG: latest
CONTAINER                         #Running instance of an image
                                  #Is either:
                                  #  - CONTAINER_ID (can be shortened)
                                  #  - CONTAINER_NAME

/var/lib/docker/                  #Runtime directory for docker with notably:
                                  #  - containers/CONTAINER_ID/:
                                  #     - log files
                                  #     - config, including routing
                                  #  - images/



docker version                    #Prints current version


docker build DIR|URL              #Creates an IMAGE from a DIR with a Dockerfile inside
-f DOCKERFILE                     #Def: DIR/Dockerfile
-t IMAGE                          #


docker rmi IMAGE                  #Deletes an IMAGE
-f
--force                           #Deletes even if there are related containers
--no-prune                        #Do not delete parents without tags


docker tag IMAGE IMAGE2           #Make IMAGE2 a link to IMAGE, i.e.:
                                  #  - IMAGE_ID IMAGE_NAME: gives a name
                                  #  - IMAGE IMAGE:TAG: create tag
                                  #  - IMAGE REPO_USER/IMAGE_NAME: associate with a repository


docker run IMAGE                  #Does:
 [COMMAND [ARGS...]]              #  - if does not exist locally, docker pull IMAGE
                                  #  - creates and run a container, using IMAGE
                                  #  - run COMMAND from within the container (def: container's default command)
-d                                #Run in the background of current terminal
--detach                          #Returns container ID
-t
--tty                             #Allocate a pseudo-TTY. Required if starting interactive shell
-i
-p 
--interactive                     #Redirect container input from current terminal's
-P
--publish-all                     #Forward all container ports to host's


docker stop CONTAINER...          #Stops a running CONTAINER
-t INT
--time INT                        #How long to wait (in secs, def: 10)


docker rm CONTAINER               #Deletes a CONTAINER
-f
--force                           #Deletes even if running


docker images                     #Prints images with information (one line per image+tag combination):
                                  #  - IMAGE (repository)
                                  #  - tag
                                  #  - sha256 checksum (if --digests)
                                  #  - image ID (truncated unless --no-trunc)
                                  #  - ctime
                                  #  - size
-a
--all                             #Prints all (do not hide intermediate images, i.e. currently building images)
-q
--quiet                           #Only show image ID


docker ps                         #Prints containers with information:
                                  #  - container ID (truncated unless --no-trunc)
                                  #  - container names
                                  #  - IMAGE name
                                  #  - IMAGE command
                                  #  - ctime
                                  #  - status: exited (+ status code, time)
                                  #  - ports forwarding
                                  #  - size (real, virtual): only if -s/--size
-a                                
--all                             #Prints all (not only currently running)
-n [INT]
--last [INT]
-l
--latest                          #Only prints INT (def: 1) latest ran
-q
--quiet                           #Only show container ID


docker logs CONTAINER             #Prints logs of a container (i.e. stdout/stderr)
-t
--timestamps                      #Print timestamps too
--details                         #Verbose
-f
--follow                          #Pipe input, i.e. does not end
--tail NUM                        #Only last NUM lines
--since DATE[TIME]                #


                                             /=+===============================+=\ 
                                            /  :                               :  \  
                                            )==:          DOCKERFILE           :==(   
                                            \  :_______________________________:  /    
                                             \=+===============================+=/


FILESYSTEM ==>                    #/ is image root

/Dockerfile                       #Main configuration file, with following commands

FROM IMAGE                        #Pull another IMAGE

COMMAND                           #Means a CLI command, either:
                                  #  - same syntax as in a CLI
                                  #    Run with /bin/sh -c
                                  #  - as array of words ["STR",...]
                                  #    Run with exec, i.e. new environment

RUN COMMAND                       #Run command

ENTRYPOINT COMMAND                #If COMMAND uses:
                                  #  - array of words: like CMD
                                  #  - CLI syntax: sets default command, that can take args.

CMD COMMAND                       #If ENTRYPOINT was:
                                  #  - not called before: sets default command, that cannot take args. 
                                  #  - called before: sets default args.
                                  #Only last CMD will be used.

ENV VAR VAL                       #Sets ENVVAR


                                             /=+===============================+=\ 
                                            /  :                               :  \  
                                            )==:          DOCKER HUB           :==(   
                                            \  :_______________________________:  /    
                                             \=+===============================+=/


GOAL ==>                          #Repository (similar to GitHub) of Docker images
                                  #Can create/edit via website.

docker login [HOSTNAME]           #Authenticate to Docker Hub from CLI
                                  #Used when trying to push to repo
-p PASSWORD
--password PASSWORD
-u USER
--user USER                       #Def: use interactive prompt


docker push IMAGE                 #Push IMAGE to associated repo. IMAGE must include "REPO_USER/"

docker pull IMAGE                 #Pull IMAGE from associate repo. IMAGE must include "REPO_USER/"
-a
--all-tags                        #Pull all related tags as well<commit_msg>no commit message<commit_after>
            
   DOCKER   
            



                                             /=+===============================+=\ 
                                            /  :                               :  \  
                                            )==:         DOCKER ENGINE         :==(   
                                            \  :_______________________________:  /    
                                             \=+===============================+=/

VERSION ==>                       #1.12.2

docker deamon:
  - binds to Unix socket:
     - owned by "docker" group if it exists, "root" (avoid) otherwise
  - client is connected to daemon (client-server architecture)

Start deaemon:
  - once: sudo service docker start
  - all the time: sudo systemctl enable docker

Memory and swap accouting:
  - must be enabled on the OS: performance impact, but better OS memory management
  - see online doc for how to enable it

IMAGE                             #Stateless filesystem snapshot, with metadata
                                  #IMAGE from Docker Hub.
                                  #Pulled unless cached
                                  #Is either:
                                  #  - IMAGE_ID (can be shortened)
                                  #  - [HOSTNAME/][REPO_USER/]IMAGE_NAME[:TAG]:
                                  #     - def HOSTNAME: registry-1.docker.io
                                  #     - REPO_USER (if push|pull, def: docker): see Docker Hub
                                  #     - IMAGE_NAME: [[:alnum:]._-]
                                  #     - def TAG: latest
CONTAINER                         #Running instance of an image
                                  #Is either:
                                  #  - CONTAINER_ID (can be shortened)
                                  #  - CONTAINER_NAME

/var/lib/docker/                  #Runtime directory for docker with notably:
                                  #  - containers/CONTAINER_ID/:
                                  #     - log files
                                  #     - config, including routing
                                  #  - images/



docker version                    #Prints current version


docker commit CONTAINER [IMAGE]   #Creates a new (or copies to an) IMAGE, from an existing CONTAINER
-a AUTHOR
--author AUTHOR                   #
-m COMMIT_MESSAGE
--message COMMIT_MESSAGE          #
-c COMMAND
--change COMMAND                  #Execute Dockerfile command


docker build DIR|URL              #Creates an IMAGE from a DIR with a Dockerfile inside
                                  #Each instruction creates a new "layer":
                                  #  - i.e. a new CONTAINER, then docker commit it to a new IMAGE
                                  #  - intermediate IMAGE are removed at the end
                                  #  - max 127 layers
-f DOCKERFILE                     #Def: DIR/Dockerfile
-t IMAGE                          #


docker rmi IMAGE                  #Deletes an IMAGE
-f
--force                           #Deletes even if there are related containers
--no-prune                        #Do not delete parents without tags


docker tag IMAGE IMAGE2           #Make IMAGE2 a link to IMAGE, i.e.:
                                  #  - IMAGE_ID IMAGE_NAME: gives a name
                                  #  - IMAGE IMAGE:TAG: create tag
                                  #  - IMAGE REPO_USER/IMAGE_NAME: associate with a repository


docker run IMAGE                  #Does:
 [COMMAND [ARGS...]]              #  - if does not exist locally, docker pull IMAGE
                                  #  - creates and run a container, using IMAGE
                                  #  - run COMMAND from within the container (def: container's default command)
-d                                #Run in the background of current terminal
--detach                          #Returns container ID
-t
--tty                             #Allocate a pseudo-TTY. Required if starting interactive shell
-i
--interactive                     #Redirect container input from current terminal's
-p HOST_PORT:CONTAINER_PORT       #Forward ports
-P
--publish-all                     #Forward any opened CONTAINED_PORT to a random HOST_PORT (ephemeral port range, i.e. 32768-61000)


docker stop|restart CONTAINER...  #Stops a running CONTAINER
                                  #If restart, runs docker start right after
-t INT
--time INT                        #How long to wait (in secs, def: 10)


docker start CONTAINER...         #Runs a stopped CONTAINER


docker rm CONTAINER               #Deletes a CONTAINER
-f
--force                           #Deletes even if running


docker images                     #Prints images with information (one line per image+tag combination):
                                  #  - IMAGE (repository)
                                  #  - tag
                                  #  - sha256 checksum (if --digests)
                                  #  - image ID (truncated unless --no-trunc)
                                  #  - ctime
                                  #  - size
-a
--all                             #Prints all (do not hide intermediate images)
-q
--quiet                           #Only show image ID


docker ps                         #Prints containers with information:
                                  #  - container ID (truncated unless --no-trunc)
                                  #  - container names
                                  #  - IMAGE name
                                  #  - IMAGE command
                                  #  - ctime
                                  #  - status: exited (+ status code, time)
                                  #  - ports forwarding
                                  #    Can also use: docker port CONTAINER [HOST_PORT]
                                  #  - size (real, virtual): only if -s/--size
-a                                
--all                             #Prints all (not only currently running)
-n [INT]
--last [INT]
-l
--latest                          #Only prints INT (def: 1) latest ran
-q
--quiet                           #Only show container ID


docker logs CONTAINER             #Prints logs of a container (i.e. stdout/stderr)
-t
--timestamps                      #Print timestamps too
--details                         #Verbose
-f
--follow                          #Pipe input, i.e. does not end
--tail NUM                        #Only last NUM lines
--since DATE[TIME]                #


docker top CONTAINER              #Prints running processes of a container: UID, PID, parent PID, time, command, TTY, etc.


docker inspect 
 CONTAINER|IMAGE|TASK             #Prints verbose debug information, as JSON


                                             /=+===============================+=\ 
                                            /  :                               :  \  
                                            )==:          DOCKERFILE           :==(   
                                            \  :_______________________________:  /    
                                             \=+===============================+=/


FILESYSTEM ==>                    #/ is image root

/Dockerfile                       #Main configuration file, with following commands

FROM IMAGE                        #Pull another IMAGE

COMMAND                           #Means a CLI command, either:
                                  #  - same syntax as in a CLI
                                  #    Run with /bin/sh -c
                                  #  - as array of words ["STR",...]
                                  #    Run with exec, i.e. new environment

RUN COMMAND                       #Run command

ENTRYPOINT COMMAND                #If COMMAND uses:
                                  #  - array of words: like CMD
                                  #  - CLI syntax: sets default command, that can take args.

CMD COMMAND                       #If ENTRYPOINT was:
                                  #  - not called before: sets default command, that cannot take args. 
                                  #  - called before: sets default args.
                                  #Only last CMD will be used.

ENV VAR VAL                       #Sets ENVVAR

MAINTAINER NAME <EMAIL>           #Metadata


                                             /=+===============================+=\ 
                                            /  :                               :  \  
                                            )==:          DOCKER HUB           :==(   
                                            \  :_______________________________:  /    
                                             \=+===============================+=/


GOAL ==>                          #Repository (similar to GitHub) of Docker images
                                  #Can create/edit via website.

docker login [HOSTNAME]           #Authenticate to Docker Hub from CLI
                                  #Used when trying to push to repo
-p PASSWORD
--password PASSWORD
-u USER
--user USER                       #Def: use interactive prompt


docker push IMAGE                 #Push IMAGE to associated repo. IMAGE must include "REPO_USER/"


docker pull IMAGE                 #Pull IMAGE from associate repo. IMAGE must include "REPO_USER/"
-a
--all-tags                        #Pull all related tags as well


docker search STR                 #Searches DockerHub, and prints results: name, description, stars, 
--limit NUM                       #
--no-trunc                        #Do not truncate description
{'fraction_non_alphanumeric': 0.11505605979711693, 'fraction_numerical': 0.0020822210357714895, 'mean_word_length': 0.9240883410374936, 'pattern_counts': {'":': 1, '<': 4, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 188, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2281970', 'n_tokens_mistral': 6222, 'n_tokens_neox': 5769, 'n_words': 1364}