我有这个Dockerfile
:
FROM chekote/gulp:latest
USER root
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y sudo libltdl-dev
ARG dockerUser='my-user-name';
ARG group='docker';
# crate group if not exists
RUN if ! grep -q -E "^$group:" /etc/group; then groupadd $group; fi
# create user if not exists
RUN if ! grep -q -E "^$dockerUser:" /etc/passwd; then useradd -c 'Docker image creator' -m -s '/bin/bash' -g $group $dockerUser; fi
# add user to the group (if it was present and not created at the line above)
RUN usermod -a -G ${group} ${dockerUser}
# set default user that runs the container
USER ${dockerUser}
我这样构建:
docker build --tag my-gulp:latest .
最后以script
这种方式运行:
#!/bin/bash
image="my-gulp:latest";
workDir='/home/gulp/project';
docker run -it --rm \
-v $(pwd):${workDir} \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /usr/bin/docker:/usr/bin/docker \
${image} /bin/bash
让我正确登录到 docker 容器,但是当我想查看图像时
docker images
或尝试拉图像
docker pull hello-world:latest
我收到此错误:
尝试在 unix:///var/run/docker.sock 连接到 Docker 守护程序套接字时获得权限被拒绝:获取http://%2Fvar%2Frun%2Fdocker.sock/v1.38/images/json:拨打 unix /var/run/docker.sock:连接:权限被拒绝
如何从中创建 docker 映像,chekote/gulp:latest
以便我可以在其中使用 docker 而不会出现错误?
或者错误可能是因为错误的 docker run 命令?