小编Bon*_*zai的帖子

Docker容器内部:“错误:无法打开显示:localhost:11.0”

我正在尝试通过ssh在Docker容器中使用带有图形界面的程序。

目前,我通过docker和容器正在运行的外部机器上的ssh连接。在主机上,我可以启动正确显示的程序,例如firefox。通过以下方式建立连接:

ssh -Y root@host
Run Code Online (Sandbox Code Playgroud)

当我在docker容器中尝试相同的操作时,带有firefox图像(见下文):

docker run -it --privileged --rm \
    -e DISPLAY=$DISPLAY \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -v /root/.Xauthority:/root/.Xauthority:rw \
    firefox
Run Code Online (Sandbox Code Playgroud)

我得到:

Error: cannot open display: localhost:11.0
Run Code Online (Sandbox Code Playgroud)

我已经尝试xhost +在主机上进行设置,但是仍然无法正常工作。主机运行,Scientific Linux release 7.2并且使用Dockerfile从 http://fabiorehm.com/blog/2014/09/11/running-gui-apps-with-docker/创建了Docker映像 :

FROM ubuntu:14.04

RUN apt-get update && apt-get install -y firefox

# Replace 1000 with your user / group id
RUN export uid=1000 gid=1000 && \
    mkdir -p /home/developer && \
    echo "developer:x:${uid}:${gid}:Developer,,,:/home/developer:/bin/bash" >> /etc/passwd && …
Run Code Online (Sandbox Code Playgroud)

x11 xserver docker

3
推荐指数
1
解决办法
6729
查看次数

为UICollectionView创建最大单元数

如何让应用程序在点击25个单元格后停止从阵列创建单元格?就目前而言,数组"cellArray"包含超过25个元素,并且没有代码可以阻止程序生成单元格.

CollectionViewContoller.m:

    @implementation CollectionViewController

//Delegate Methods

-(NSInteger) numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    return 1;
}

-(NSInteger) collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return self.cellArray.count;
}

-(UICollectionViewCell*) collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    Cell * aCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"bingoCell1" forIndexPath:indexPath];
    aCell.cellContent.text = self.cellArray[indexPath.row];
    return aCell;
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view.

        self.cellArray =
      @[@"Type 1", @"Type …
Run Code Online (Sandbox Code Playgroud)

objective-c ios

1
推荐指数
1
解决办法
1280
查看次数

标签 统计

docker ×1

ios ×1

objective-c ×1

x11 ×1

xserver ×1