Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running docker container #348

Closed
latot opened this issue Oct 14, 2022 · 6 comments
Closed

Running docker container #348

latot opened this issue Oct 14, 2022 · 6 comments

Comments

@latot
Copy link

latot commented Oct 14, 2022

Hi, I'm trying to run a temporary container from this lib, the idea is can set it up, work, and then close the process, docker will clean the files:

This will setup temporary Postgres Database with Postgis support (spatial data):

postgres <- processx::process$new(
    "docker",
    c(
        "run",
        "--rm",
        "-p", "5433:5432",
        "-e", "POSTGRES_USER=user",
        "-e", "POSTGRES_PASSWORD=password",
        "-e", "POSTGRES_DB=db",
        "postgis/postgis",
        "-c", "max_worker_processes=8",
        "-c", "max_parallel_workers=7",
        "-c", "max_parallel_workers_per_gather=7",
        "-c", "max_parallel_maintenance_workers=7"
    ),
    stdout = "|", stderr = "|"
)

Well, this is weird, because, first, I don't have any logs here, second, what I got is this:

> postgres
PROCESS 'docker', running, pid 27057.
#wait a few seconds
> postgres
PROCESS 'docker', finished.

So, for some reason it just finished.... D:

I tryied to use read_output_lines() but nothing.

Thx!

@gaborcsardi
Copy link
Member

I cannot reproduce this, for me the container is running happily. (I only had to add --platform=linux/amd64 on arm Linux.)

What do

postgres$get_exit_status()
postgres$read_error()

say?

@latot
Copy link
Author

latot commented Oct 14, 2022

Hi, I try put the param on docker, sadly, does not works, I should had provided more info.

I'm using Gentoo 64 (Linux)

> postgres <- processx::process$new(
    "docker",
    c(
        "run",
        "--rm",
        "-p", "5433:5432",
        "-e", "POSTGRES_USER=user",
        "-e", "POSTGRES_PASSWORD=password",
        "-e", "POSTGRES_DB=db",
        "postgis/postgis",
        "-c", "max_worker_processes=8",
        "-c", "max_parallel_workers=7",
        "-c", "max_parallel_workers_per_gather=7",
        "-c", "max_parallel_maintenance_workers=7", "--platform=linux/amd64"
    ))
> postgres
PROCESS 'docker', running, pid 94310.
> postgres
PROCESS 'docker', running, pid 94310.
> postgres
PROCESS 'docker', running, pid 94310.
> postgres
PROCESS 'docker', finished.
> postgres
PROCESS 'docker', finished.
> postgres$get_exit_status()
[1] 125
> postgres$read_error()
Error in `process_get_error_connection(self, private)`:
! stderr is not a pipe.
Type .Last.error to see the more details.
> .Last.error
<rlib_error_3_0/rlib_error/error>
Error in `process_get_error_connection(self, private)`:
! stderr is not a pipe.
---
Backtrace:
1. postgres$read_error()
2. processx:::process_read_error(self, private, n)
3. processx:::process_get_error_connection(self, private)
4. processx:::throw(new_error("stderr is not a pipe."))

@gaborcsardi
Copy link
Member

You still need to use stdout = "|", stderr = "|" to be able to read the standard output and error.

@latot
Copy link
Author

latot commented Oct 14, 2022

Well, there is a weird things:

  • I notice there was a running docker in the same port, so the error tells me that
  • Using kill on the process, literally kills it, don't close it, due to that, seems docker is not able to clean the container (is runing with --rm)
  • I don't get why we need platform from R, in the terminal all works fine without that param.

Instead kill, interrupt does the trick :)

Thx!

@gaborcsardi
Copy link
Member

  • Using kill on the process, literally kills it, don't close it, due to that, seems docker is not able to clean the container (is runing with --rm)

You can use $signal(15) to send a SIGTERM, that is better than SIGINT and SIGKILL.

I don't get why we need platform from R, in the terminal all works fine without that param.

You might not, I needed it, because I am on an arm machine, and this container seems to be amd64 only.

@latot
Copy link
Author

latot commented Oct 14, 2022

Hi, seems signal 15 does not close it, for now only works interrupt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants