Installed Chrome and ChromeDriver in WSL, and ensured google-chrome can be used to open a Linux-side Chrome page inside an X server window in Windows.
Ran an example script which uses selenium (fp2_14.py here) by docker exec -it loving_benz python3 /opt/pricer/fp2_14.py, while a warning appeared as "The version of chrome cannot be detected. Trying with latest driver version".
Expected:
The script can run successfully, and a Chrome page will be opened inside the X server window.
**Reproduction:**
1. Installed Chrome and ChromeDriver in WSL, and ensured `google-chrome` can be used to open a Linux-side Chrome page inside an X server window in Windows.
2. Ran an example script which uses `selenium` (fp2_14.py here) by `docker exec -it loving_benz python3 /opt/pricer/fp2_14.py`, while a warning appeared as "The version of chrome cannot be detected. Trying with latest driver version".
**Expected:**
The script can run successfully, and a Chrome page will be opened inside the X server window.
**Research:**
1. Installed ChromeDriver in WSL2:
https://www.gregbrisebois.com/posts/chromedriver-in-wsl2/
2. I also tried to make `snap install chromium` work before trying to directly install ChromeDriver in WSL, but the solution listed here just failed in my system:
https://github.com/microsoft/WSL/issues/2374#issuecomment-699110721
I think the following steps should be considered to take.
I checked chrome --version in my container shell and it suggested that such necessary dependencies were not installed inside my docker container. In this case, I may install them first.
Ensure that the ChromeDriver version matches the version of Chrome installed inside the Docker container, which should be ChromeDriver 86.0.4240.22 (398b0743353ff36fb1b82468f63a3a93b4e2e89e-refs/branch-heads/4240@{#378}).
**Next Steps:**
I think the following steps should be considered to take.
1. I checked `chrome --version` in my container shell and it suggested that such necessary dependencies were not installed inside my docker container. In this case, I may install them first.
2. Ensure that the ChromeDriver version matches the version of Chrome installed inside the Docker container, which should be `ChromeDriver 86.0.4240.22 (398b0743353ff36fb1b82468f63a3a93b4e2e89e-refs/branch-heads/4240@{#378})`.
Note that status code 127 is usually used by bash and bash-like shells to indicate that the command was not found. You can access the return code (status code) from the $? variable on both Unix and Windows.
On Windows, this is documented here:
get-help about_Automatic_Variables
Note that status code 127 is usually used by bash and bash-like shells to indicate that the command was not found. You can access the return code (status code) from the $? variable on both Unix and Windows.
On Windows, this is documented here:
`get-help about_Automatic_Variables`
The underlying issue is that the ansible playbook isn't complete, and the play on this line needs to be troubleshot so the container starts back up with systemd, so snap will run:
The underlying issue is that the ansible playbook isn't complete, and the play on this line needs to be troubleshot so the container starts back up with systemd, so snap will run:
https://gogs.gtsplab.com:5432/SVIG/pricer/src/main/basic_checks.yml#L109
You want the container to be started, not created.
You may need to call this with the state parameter as present first to make sure your name and image parameters are referring to the container created earlier in the playbook:
An important tool for troubleshooting the docker container restart with systemd is to run ansible in check mode like this:
```
$ ansible -C -m community.docker.docker_container -a "name=dev image=dev" localhost
localhost | CHANGED => {
"actions": [
{
"create_parameters": {
"AttachStderr": true,
"AttachStdin": false,
"AttachStdout": true,
"ExposedPorts": {},
"Image": "dev",
"OpenStdin": null,
"StdinOnce": false
},
"created": "Created container"
}
],
"changed": true
}
```
You want the container to be *started*, not *created*.
You may need to call this with the state parameter as `present` first to make sure your name and image parameters are referring to the container created earlier in the playbook:
https://docs.ansible.com/ansible/latest/collections/community/docker/docker_container_module.html#parameter-state
I completed the playbook running to start the container with systemd and installed the chromium-chromedriver and chromium-browser packages. However, when I start snapd and udev, an error stated as:
fatal: [docker_container]: FAILED! => {"changed": false, "msg": "Error connecting: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))"}
Research & Actions Taken:
I enable "WSL Integration" in my docker setting to enable integration with Ubuntu as being suggested by another developer on StackOverflow.
Ensured the docker daemon is running by checking with the following command.
karen_zeng@Karen-hhh:/mnt/c/Users/Karen/git_Karen/Pricer$ systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2023-06-15 15:49:39 EDT; 31min ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 300 (dockerd)
Tasks: 13
Memory: 101.9M
CGroup: /system.slice/docker.service
└─300 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Jun 15 15:49:38 Karen-hhh dockerd[300]: time="2023-06-15T15:49:38.869233880-04:00" level=warning msg="Your kernel does not support cgroup blkio throttle.write_bps_device"
Jun 15 15:49:38 Karen-hhh dockerd[300]: time="2023-06-15T15:49:38.869237978-04:00" level=warning msg="Your kernel does not support cgroup blkio throttle.read_iops_device"
Jun 15 15:49:38 Karen-hhh dockerd[300]: time="2023-06-15T15:49:38.869241638-04:00" level=warning msg="Your kernel does not support cgroup blkio throttle.write_iops_device"
Jun 15 15:49:38 Karen-hhh dockerd[300]: time="2023-06-15T15:49:38.869649117-04:00" level=info msg="Loading containers: start."
Jun 15 15:49:39 Karen-hhh dockerd[300]: time="2023-06-15T15:49:39.465451810-04:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address"
Jun 15 15:49:39 Karen-hhh dockerd[300]: time="2023-06-15T15:49:39.515818550-04:00" level=info msg="Loading containers: done."
Jun 15 15:49:39 Karen-hhh dockerd[300]: time="2023-06-15T15:49:39.567246569-04:00" level=info msg="Docker daemon" commit="20.10.21-0ubuntu1~22.04.3" graphdriver(s)=overlay2 version=20.10.21
Jun 15 15:49:39 Karen-hhh dockerd[300]: time="2023-06-15T15:49:39.567724635-04:00" level=info msg="Daemon has completed initialization"
Jun 15 15:49:39 Karen-hhh systemd[1]: Started Docker Application Container Engine.
Jun 15 15:49:39 Karen-hhh dockerd[300]: time="2023-06-15T15:49:39.594627432-04:00" level=info msg="API listen on /run/docker.sock"
Also, I verified that the docker daemon socket is accessible
I completed the playbook running to start the container with systemd and installed the chromium-chromedriver and chromium-browser packages. However, when I start snapd and udev, an error stated as:
```
fatal: [docker_container]: FAILED! => {"changed": false, "msg": "Error connecting: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))"}
```
**Research & Actions Taken:**
1. I enable "WSL Integration" in my docker setting to enable integration with Ubuntu as being suggested by another developer on StackOverflow.
2. Ensured the docker daemon is running by checking with the following command.
```
karen_zeng@Karen-hhh:/mnt/c/Users/Karen/git_Karen/Pricer$ systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2023-06-15 15:49:39 EDT; 31min ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 300 (dockerd)
Tasks: 13
Memory: 101.9M
CGroup: /system.slice/docker.service
└─300 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Jun 15 15:49:38 Karen-hhh dockerd[300]: time="2023-06-15T15:49:38.869233880-04:00" level=warning msg="Your kernel does not support cgroup blkio throttle.write_bps_device"
Jun 15 15:49:38 Karen-hhh dockerd[300]: time="2023-06-15T15:49:38.869237978-04:00" level=warning msg="Your kernel does not support cgroup blkio throttle.read_iops_device"
Jun 15 15:49:38 Karen-hhh dockerd[300]: time="2023-06-15T15:49:38.869241638-04:00" level=warning msg="Your kernel does not support cgroup blkio throttle.write_iops_device"
Jun 15 15:49:38 Karen-hhh dockerd[300]: time="2023-06-15T15:49:38.869649117-04:00" level=info msg="Loading containers: start."
Jun 15 15:49:39 Karen-hhh dockerd[300]: time="2023-06-15T15:49:39.465451810-04:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address"
Jun 15 15:49:39 Karen-hhh dockerd[300]: time="2023-06-15T15:49:39.515818550-04:00" level=info msg="Loading containers: done."
Jun 15 15:49:39 Karen-hhh dockerd[300]: time="2023-06-15T15:49:39.567246569-04:00" level=info msg="Docker daemon" commit="20.10.21-0ubuntu1~22.04.3" graphdriver(s)=overlay2 version=20.10.21
Jun 15 15:49:39 Karen-hhh dockerd[300]: time="2023-06-15T15:49:39.567724635-04:00" level=info msg="Daemon has completed initialization"
Jun 15 15:49:39 Karen-hhh systemd[1]: Started Docker Application Container Engine.
Jun 15 15:49:39 Karen-hhh dockerd[300]: time="2023-06-15T15:49:39.594627432-04:00" level=info msg="API listen on /run/docker.sock"
```
3. Also, I verified that the docker daemon socket is accessible
You don't want to use that module to run commands in the container, because that's what docker_container_exec is for. The command argument for this module refers to the command to use to start up a new container, like for docker run or the RUN statement in a Dockerfile.
Even still, you should use the real module (snap) directly:
# command line version
ansible -m systemd -a 'state=started name=snapd' docker_container
# playbook version
- name: Start the snapd service
hosts: docker_container
tasks:
- name: Start snapd service
systemd:
name: snapd
state: started
You also need to do the same for udev.
The issue is that you're using the docker_container module here:
https://gogs.gtsplab.com:5432/SVIG/pricer/src/main/basic_checks.yml#L136
You don't want to use that module to run commands in the container, because that's what `docker_container_exec` is for. The `command` argument for this module refers to the command to use to start up a new container, like for `docker run` or the `RUN` statement in a Dockerfile.
Even still, you should use the real module (snap) directly:
```
# command line version
ansible -m systemd -a 'state=started name=snapd' docker_container
# playbook version
- name: Start the snapd service
hosts: docker_container
tasks:
- name: Start snapd service
systemd:
name: snapd
state: started
```
You also need to do the same for udev.
Another issue occurred after changing to use the real module (snap) as shown above, and it indicated the failure to find the required service snapd on the host.
fatal: [docker_container]: FAILED! => {"changed": false, "msg": "Could not find the requested service snapd: host"}
The following steps help to fix this error.
Ensure 'snapd' package is installed on the host.
Check the exact name of the systemd service for snapd on my system (which means the one shown in the playbook may be modified due to different systems used). In the container shell, I run the following command:
systemctl list-unit-files | grep snapd
Another issue occurred after changing to use the real module (snap) as shown above, and it indicated the failure to find the required service snapd on the host.
```
fatal: [docker_container]: FAILED! => {"changed": false, "msg": "Could not find the requested service snapd: host"}
```
The following steps help to fix this error.
1. Ensure 'snapd' package is installed on the host.
2. Check the exact name of the systemd service for snapd on my system (which means the one shown in the playbook may be modified due to different systems used). In the container shell, I run the following command:
```
systemctl list-unit-files | grep snapd
```
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Reproduction:
google-chromecan be used to open a Linux-side Chrome page inside an X server window in Windows.selenium(fp2_14.py here) bydocker exec -it loving_benz python3 /opt/pricer/fp2_14.py, while a warning appeared as "The version of chrome cannot be detected. Trying with latest driver version".Expected:
The script can run successfully, and a Chrome page will be opened inside the X server window.
Research:
Installed ChromeDriver in WSL2:
https://www.gregbrisebois.com/posts/chromedriver-in-wsl2/
I also tried to make
snap install chromiumwork before trying to directly install ChromeDriver in WSL, but the solution listed here just failed in my system:https://github.com/microsoft/WSL/issues/2374#issuecomment-699110721
Next Steps:
I think the following steps should be considered to take.
chrome --versionin my container shell and it suggested that such necessary dependencies were not installed inside my docker container. In this case, I may install them first.ChromeDriver 86.0.4240.22 (398b0743353ff36fb1b82468f63a3a93b4e2e89e-refs/branch-heads/4240@{#378}).Note that status code 127 is usually used by bash and bash-like shells to indicate that the command was not found. You can access the return code (status code) from the $? variable on both Unix and Windows.
On Windows, this is documented here:
get-help about_Automatic_VariablesThe underlying issue is that the ansible playbook isn't complete, and the play on this line needs to be troubleshot so the container starts back up with systemd, so snap will run:
https://gogs.gtsplab.com:5432/SVIG/pricer/src/main/basic_checks.yml#L109
You also have to add a play to install the chromium-chromedriver and chromium-browser packages.
An important tool for troubleshooting the docker container restart with systemd is to run ansible in check mode like this:
You want the container to be started, not created.
You may need to call this with the state parameter as
presentfirst to make sure your name and image parameters are referring to the container created earlier in the playbook:https://docs.ansible.com/ansible/latest/collections/community/docker/docker_container_module.html#parameter-state
I completed the playbook running to start the container with systemd and installed the chromium-chromedriver and chromium-browser packages. However, when I start snapd and udev, an error stated as:
Research & Actions Taken:
What happens when you re-run the playbook with
-vvv?Run command
ansible-playbook basic_checks.yml --ask-become-pass -vvv.The issue is that you're using the docker_container module here:
https://gogs.gtsplab.com:5432/SVIG/pricer/src/main/basic_checks.yml#L136
You don't want to use that module to run commands in the container, because that's what
docker_container_execis for. Thecommandargument for this module refers to the command to use to start up a new container, like fordocker runor theRUNstatement in a Dockerfile.Even still, you should use the real module (snap) directly:
You also need to do the same for udev.
Another issue occurred after changing to use the real module (snap) as shown above, and it indicated the failure to find the required service snapd on the host.
The following steps help to fix this error.
Chromium was installed using the playbook.
46e66a20a1