Container Commands

        1. $ docker - lists all available commands
        2. $ docker run [image name] - runs image (pulls if not local), creates/starts container
        3. $ docker run -it -p 8080:3000 tomcat:8.0 -create & start container from image
        4. $ docker start [cont ID] - starts an existing container
        5. $ docker stop [cont ID] - stops a container (does NOT delete)
        6. $ docker rm [cont ID] - deletes. Add -f tag if need to force
        7. $ docker ps - lists all containers running
        8. $ docker ps -a - list all containers (running & stopped)
        9. $ docker logs [cont ID] - show logs of running container
        10. $ docker inspect <cont> - shows info on container (JSON) or image
        11. $ docker run <image-name> sleep 1000 - stop container after 1,000 seconds
        12. $ docker network ls - list docker networks
        13. $ docker network inspect [ID] - network info (including containers in it)
        14. $ docker exec [cont ID] xyz - execute command in running container
        15. $ docker exec -it <cont_id> command - “ “ & enter interactive mode
        16. $ docker exec d64 node seed.js - as if in console (d64 $ node seed.js)
        17. $ docker exec d64 bash - gain access to container’s bash shell
        18. $ docker exec -it d64 /bin/bash - enter container d64 & attach bash shell
        19. $ docker rm 198.. - deletes container (only if it is stopped)
        20. $ docker rm -f 198 - removes/force deletes container (even if running)
        21. docker stop $(docker ps -a -q) - stop ALL containers
        22. $ docker rm $(docker ps -a -q) - delete ALL stopped container
        23. $ docker system prune - delete ALL unused data (stopped cont, vol w/o container & images w/ no cont)
        24. --rm → remove container when stopped
        25. --name <contName> → name the container once it is built from image

results matching ""

    No results matching ""