> 文档中心 > docker Ubuntu系统中使用 powershell

docker Ubuntu系统中使用 powershell


docker Ubuntu系统中使用 powershell


本文地址:https://blog.csdn.net/qq_28550263/article/details/124252887:https://blog.csdn.net/qq_28550263/article/details/124252887

邮箱:291148484@163.com


目标:

  • 在docker环境中部署使用 powershell

步骤:

1. 安装docker :

sudo apt-get isntall docker

2. 拉取一个ubuntu镜像:

sudo docker pull ubuntu:latest

3. 基于镜像构建容器,并映射到外部一个端口 8000 =>8000:

sudo docker run -it -d -p 127.0.0.1:8000:8000 容器ID

4. 进入运行该容器shell环境:

sudo docker exec -it 容器ID::bin/bash

5. (在该容器中)安装 powershell

# 更新包列表sudo apt-get update# 安装必备软件包sudo apt-get install -y wget apt-transport-https software-properties-common# 下载Microsoft知识库GPG密钥wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb# 注册Microsoft知识库GPG密钥sudo dpkg -i packages-microsoft-prod.deb# 在我们添加了packages.microsoft.com之后更新包列表sudo apt-get update# 安装 PowerShellsudo apt-get install -y powershell# 运行 PowerShellpwsh

这时你就进入了powershell,如图:
在这里插入图片描述

6. 从 Powershell 退出到系统bash:

exit

7. 直接从宿主机进入容器powershell:

sudo docker exec -it 容器ID /bin/pwsh

例如:
在这里插入图片描述