gpt4 book ai didi

git - 无法通过 'docker attach'到达Bash Shell

转载 作者:行者123 更新时间:2023-12-02 18:57:05 39 4
gpt4 key购买 nike

在远程服务器上,docker正在基于nginxDockerfile运行镜像

FROM nginx

COPY ./ /usr/share/nginx/html
EXPOSE 80
CMD /usr/sbin/nginx -g "daemon off;"
docker ps显示:
CONTAINER ID        IMAGE                              COMMAND                CREATED             STATUS              PORTS                         NAMES
a71e45d5cd40 myUsername/myNginxWebsite:latest "\"/bin/sh -c '/usr/ 23 hours ago Up 23 hours 80/tcp, 443/tcp sharp_fermi

通过SSH连接到远程服务器后,运行 docker attach <container_id>将显示 nginx的输出,然后按 ctrl + qctrl + cctrl + p不会使我回到bash shell。

是否有可能进入 shell ?我想做类似 git pull的事情。

最佳答案

docker exec -it <container-id-or-name> /bin/bash
根据https://docs.docker.com/reference/commandline/cli/#exec-

Usage: docker exec [OPTIONS] CONTAINER COMMAND [ARG...]

Run a command in a running container

-d, --detach=false Detached mode: run command in the background -i, --interactive=false Keep STDIN open even if not attached -t, --tty=false Allocate a pseudo-TTY

关于git - 无法通过 'docker attach'到达Bash Shell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29910518/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com