docker常用命令

    技术2024-05-07  12

    docker command help

    docker command --help

    use images

    list images

    docker images

    start container by image

    docker run -t -i ubuntu:16.04 /bin/bash

    search images

    docker search mysql

    get new images

    docker pull ubuntu:18.04

    delete image

    docker rmi ubuntu:18.04

    more operations

    use container

    start container

    docker run -t -i ubuntu:16.04 /bin/bash ## -d background

    show containers

    docker ps -a

    stop & start & restart container

    docker start container_id ## RUN IN THE BACKGROUND docker stop container_id docker restart container_id

    enter container

    docker attach container_id ## use exit will stop container docker exec -it container_id /bin/bash ## use exit will not stop container

    export container

    docker export container_id > container.tar

    import container_snap to image

    cat docker/mysql.tar | docker import - mysql:v1

    delete container

    docker rm -f container_id

    show container’s port mapping

    docker port container_id

    connect container by port mapping

    docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD = 123456 mysql

    connect containers

    create a docker network

    docker network create -d bridge hadoop-net

    show networks

    docker network ls

    run a container and connect to the network

    docker run -itd --name hadoop1 --network hadoop-net ubuntu /bin/bash
    Processed: 0.031, SQL: 10