9/27/2023 0 Comments Debian install mysql server![]() ![]() In Windows/Mac, Docker runs in a mini-VM so to see the processes youll need to connect directly to that. ![]() # Docker Commands, Help & Tips # Show commands & management commands ``` $ docker ``` # Docker version info ``` $ docker version ``` # Show info like number of containers, etc ``` $ docker info ``` # WORKING WITH CONTAINERS # Create an run a container in foreground ``` $ docker container run -it -p 80:80 nginx ``` # Create an run a container in background ``` $ docker container run -d -p 80:80 nginx ``` # Shorthand ``` $ docker container run -d -p 80:80 nginx ``` # Naming Containers ``` $ docker container run -d -p 80:80 -name nginx-server nginx ``` # TIP: WHAT RUN DID - Looked for image called nginx in image cache - If not found in cache, it looks to the default image repo on Dockerhub - Pulled it down (latest version), stored in the image cache - Started it in a new container - We specified to take port 80- on the host and forward to port 80 on the container - We could do "$ docker container run -publish 8000:80 -detach nginx" to use port 8000 - We can specify versions like "nginx:1.09" # List running containers ``` $ docker container ls ``` OR ``` $ docker ps ``` # List all containers (Even if not running) ``` $ docker container ls -a ``` # Stop container ``` $ docker container stop ``` # Stop all running containers ``` $ docker stop $(docker ps -aq) ``` # Remove container (Can not remove running containers, must stop first) ``` $ docker container rm ``` # To remove a running container use force(-f) ``` $ docker container rm -f ``` # Remove multiple containers ``` $ docker container rm ``` # Remove all containers ``` $ docker rm $(docker ps -aq) ``` # Get logs (Use name or ID) ``` $ docker container logs ``` # List processes running in container ``` $ docker container top ``` # TIP: ABOUT CONTAINERS Docker containers are often compared to virtual machines but they are actually just processes running on your host os. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |