to-container:
docker exec -ti my_container_name bash
我希望此命令还会自动在容器内启动Pipenv shell,例如:
to-container:
docker exec -ti my_container_name bash && pipenv shell
你不能做你想做的事情。 暂时忘了docker,更不用说了。 当您调用它时,这会做什么:
bash
bash
程序成功退出,它将运行pipenv shell
。 它肯定会运行
pipenv shell
命令。 您想要这个或类似的东西:
bash
This will start a bash -c 'pipenv shell'
program and ask it to run the
bash
command, then (after pipenv shell
completes) exit.
pipenv shell
将自我启动一个交互式外壳(据我所知,我不使用
pipenv shell
)。 这有点粗糙,因为您有两个炮弹,但这没什么大不了的。要将其转换为docker,您将使用:
pipenv
然后将其放入您的makefile中:
docker exec -ti my_container_name bash -c 'pipenv shell'
我知道我参加聚会迟到了。但是我今天就偶然发现了这个页面。因此,对于任何之后的人来说。我认为您可能需要在〜/.bashrc文件中设置to-container:
docker exec -ti my_container_name bash -c 'pipenv shell'
,因为每次访问bash时,该文件都会加载。,例如,在我的dockerfile中,我的工作迪尔设置为/opt/app/,而我的pipfile在同一目录下。因此,我只需要在.bashrc文件的末尾添加
pipenv shell
。瞧!运行
pipenv shell
将直接进入Pipenv环境。
使用
bash exec -ti container-name /bin/bash
环境变量!SHELL=bash
docker exec --env=SHELL=bash -ti my_container_name pipenv shell