Dockerfile: Copy command on windows container fails with "Access Denied" - docker

I am trying to run a web application implemented with php, js, html together with Selenium to test functionality. I am using a python script together with pytest to run the selenium tests against the web application. The web application is already dockerized with a windows/servercore:ltsc2019 base image and the xampp application. If the dockerfile is build for the first time it succeeds. But if some changes are done and the container has to be rebuilded i get the following error:
Status: failed to copy files: failed to copy directory: chtimes \\?\Volume{06ac6f98-32bd-4e73-b16b-f982f49c7bd6}\xampp\htdocs\img: Access denied
on this Dockerfile step:
Step 2/7 : COPY . C:\\xampp\\htdocs
I am using the already dockerized web application (including docker-compose) and an existing gitlab pipeline. After adding selenium and python services to docker-compose I found out that they are only available on linux containers so I switched the docker engine to experimental to make use of the mixed mode. And that was working just fine for my pc at work (I tested it there). But then I used the same docker-compose file on my home pc and I got the error from above. Also on the gitlab-runner that runs the pipeline the same error occured after modifying the pipeline slightly (Added point 2-4).
Run web application container
docker-compose -f ./docker/stage/docker-compose-staging.yml --compatibility up --build -d
Switch daemon to linux container with powershell script
./docker-e2e-tests/SwitchDaemon.ps1
Run the test containers (Selenium, python)
docker-compose -f ./docker-e2e-tests/docker-compose.yml --compatibility up --build -d
Switch daemon back to windows container with powershell script
./docker-e2e-tests/SwitchDaemon.ps1
Same result here. First time it was fine. Second time I tried to COPY the changes into the container (step 1) I got the same error as above. And now the worst problem is, that the pipeline is not running anymore at all. I am even getting the same error now if I remove step 2-4.

Related

Can't create a remote interpreter with Docker-compose

Hello guys i need your help!
I can't configure the remote docker-compose interpreter in PyCharm, I keep getting the following error:
and the corresponding log entry:
2020-08-09 02:45:55,299 [6304130] WARN -
ckaging.InstalledPackagesPanel - The following command was executed:
C:\Program Files\JetBrains\PyCharm 2020.1.3\bin\runnerw64.exe
C:\Users\Angel\Downloads\docker-compose-Windows-x86_64.exe -f
D:\Archiv\Projects\PycharmProjects\django_with_db\docker-compose.yml
-f C:\Users\Angel\AppData\Local\JetBrains\PyCharm2020.2\tmp\docker-compose.override.241.yml
run --rm --no-deps web
The exit code: 1
The error output of the command:
Couldn't find docker binary. You might need to install Docker:
https://docs.docker.com/engine/installation/windows/
docker-compose finished with exit code 1
In my case, PyCharm is installed on Windows 10, and Docker and Docker-compose are on a separate server running CentOS and I use the following settings:
Docker:
Interpreter:
At the same time, Docker as a remote interpreter works fine, the problem only concerns the docker-compose.
I don't know if this matter or not, but I want to point out, that since Docker is not installed on a windows host, when I first tried to create a remote interpreter using docker-compose, PyCharm showed a message – can’t find the docker-compose executable. To overcome this, I downloaded the executable for my platform from the official Docker repository and manually specify the path to it:
Whether this is the right solution I don't know, but it's works
I am using the following software versions:
Windows 10 build 19041
PyCharm Professional 2020.2
CentOS Linux release 8.2.2004
Docker version 19.03.12, build 48a66213fe
docker-compose version 1.26.2, build eefe0d31

Set up Docker Build Step in Bamboo

I am currently despairing at the attempt of setting up a docker build step in Atlassian Bamboo.
For starters, I just want to create a build configuration that runs the hello-world image as a proof of confluence. So far, I have failed.
I have tried following the steps on https://confluence.atlassian.com/bamboo0609/using-bamboo/jobs-and-tasks/configuring-tasks/configuring-the-docker-task-in-bamboo , but to no avail.
My setup is this:
We have Bamboo installed on an Ubuntu server. I also installed Docker on that server and added the bamboo user to the docker usergroup and restarted the server to make sure the permission change takes effect. At this point, docker run hello-world works when I run it directly on the server. I can also confirm that this is the server that Bamboo runs on since Bamboo went offline whenever I restarted the server that I installed Docker on.
Then, I have added the docker capability to the server (the agent is the default agent, so it inherits this capability from the server). As the docker path, I have tried various things, none of which worked (aka, the following errors remained the same for each of these):
/snap/docker (the first folder that I found on a manual search)
/usr/bin/docker (the recommended path, though on inspecting the Ubuntu server I quickly found out that no docker folder exists under /usr/bin on the Ubuntu derver)
/var/snap/docker/common/var-lib-docker (the path that Docker returns as its Root Directory when I run docker info on the Ubuntu server)
/var/snap/docker (for good measure)
Now, for the runner, I have tried two different approaches.
First, I tried using a Docker runner with the following settings:
Command: Run a Docker container
Docker image: hello-world
This returns the following error message:
┊
Error occurred while running Task 'Hello World Docker Test(5)' of type com.atlassian.bamboo.plugins.bamboo-docker-plugin:task.docker.cli.com.atlassian.bamboo.task.TaskException: Failed to execute task
┊
Caused by: com.atlassian.bamboo.docker.DockerException: Error running Docker run command
┊
Caused by: com.atlassian.utils.process.ProcessException: Error executing /snap/docker run --volume /var/atlassian/application-data/bamboo/xml-data/build-dir/CAM-DOC-JOB1:/data --workdir /data --rm hello-world
┊
The second was just to run a shell runner for the command docker run hello-world, which returned the following error:
docker: not found
At this point, I feel like I'm out of ideas. Everything points towards Bamboo for some reason not finding Docker on the server, even though I can clearly confirm that it is there. I have tried various different approaches of telling Bamboo where to find Docker, but none of them have worked.
It's obvious that I'm doing something wrong, but I can't figure out what. Or maybe the problem lies in an entirely different direction altogether? Anyway, I would be grateful for any insight shared on this matter.
Okay, I found out what caused this strange behaviour.
The problem was that I installed Docker using sudo snap install docker, and apparently installing docker via snap causes problems with Bamboo.
So I got it to work using these simple steps:
[Server] Uninstalled Snap Docker using sudo snap remove docker
[Server] Reinstalled Docker using sudo apt install docker.io
[Bamboo] Changed the path to Docker in the Server Capabilities to /usr/bin/docker
After that, the hello-world image build succeeded and printed the expected output to the log.

How to build windows server core on Windows 10 Pro?

I have the following basic Dockerfile:
FROM mcr.microsoft.com/windows/servercore:1903
CMD echo Hello World!
When I run the command:
docker build -t latest . or docker build .
My terminal hangs forever and it seems like nothing is being done.
However, if I run:
docker pull mcr.microsoft.com/windows/servercore:1903
I can pull the image from the repository.
I'm not sure what I'm doing wrong, or how to fix it. The build command doesn't seem to have a verbose option, and I need a docker container running Windows.
I'm using Docker in Windows 10 Pro and its configured to use Windows containers.
Check which directory do you execute your commands from. You shall be executing them from directory where DOCKERFILE is located and nothing else. If you execute say from root of C drive or any other location with big number of files then docker as a first step will try to zip all of them up and then send to a builder and hence delays.

Error building Docker image in Windows 7

New to docker and I'm using Windows 7 SP1. It looks like docker is running fine in my machine as I have tried running hello-world by command docker run hello-world as instructed in the tutorial and got expected result. Now all I'm trying to do is create a docker image for a .net core console app. My app built and ran. but while building docker image by command docker build -t myapp . I get the below error
error during connect: Post http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.30/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&c
puquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&labels=%7B%7D&memory=0&memswap=0&networkmode=default&rm=1&shmsize=0&t=
duke&target=&ulimits=null: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on
Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.
Below my Dockerfile
FROM microsoft/dotnet:1.1-runtime-nanoserver
WORKDIR /DotNetConsole
COPY /bin/Debug/netcoreapp1.1/publish/ .
ENTRYPOINT ["dotnet", "DotNetConsole.dll"]
I could get around this problem by starting the "Docker QuickStart Terminal" installed with the docker tools, and running the commands for building the docker images from there.
If I used GIT BASH instead of the Docker QuickStart Terminal to execute the commands, I would get this kind of error. So it seems that if the commands are not executed from the Docker terminal itself, these errors show up.

docker-compose returning apache2-foreground not found

I have two simple containers, web and db. I built and can successfully up the containers via docker-compose on both Windows and Ubuntu. However, when I attempt to up on Photon, I get the following error for my web container.
Handler for POST /v1.21/containers/.../start returned error: Container command 'apache2-foreground' not found or does not exist.
But when I build the image based on the Dockerfile, and docker run web, it launches and runs fine. Any ideas about this error?
apache2-foreground is a command (script) that calls apache2 -DFOREGROUND (see httpd/php repos/containers). It's the command automatically run by php/httpd containers
If you run into a problem running a command from docker-compose that will ordinarily run with docker then it could probably be a bug - see this for instance
It could also be the case that you actually have bad paths in your docker-compose.yml volume mappings

Resources