I want to install the library in the Docker environment

Asked 3 months ago, Updated 3 months ago, 7 views

I am currently developing an application with Ruby on Rails, which has created a development environment with Docker.Among them (in this case), I would like to install and use a library called imagemagic in Rails, but I am having trouble because I do not know how to install the library in the development environment of Docker.As a result, how can I install imagemagic?

I have been able to develop Docker's Rails development environment myself and implement it well, but while groping for other commands, Docker's knowledge remains shallow...

As a trial, I tried the installation described at the URL below.
Here's the command.

$sudo apt-get update
Password: (my password)
sudo:apt-get:command not found

Maybe it's because of Docker's environment.The command is incorrect.

I looked it up and remembered what I wrote in the Dockerfile when I installed Ruby and PostgreSQL on Docker.
Therefore, I thought Dockerfile might be used when installing libraries like imagemagic, so I looked into the direction.
"However, perhaps because of my lack of knowledge, I searched ""Install Dockerfile Library"" and found no correct information because it was overflowing with multiple information..."

The current Dockerfile is as follows:

 FROM ruby: 2.5
RUN apt-get update-qq&apt-get install-y nodejs postgresql-client
RUN mkdir /myapp
COPY Gemfile/myapp/Gemfile
COPY Gemfile.lock/myapp/Gemfile.lock
RUN bundle install

# Add a script to be executed every time the container starts.
COPY entrypoint.sh/usr/bin/
RUN chmod+x/usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]

# Start the main process.
CMD ["rails", "server", "-b", "" ]

There is a similar description in the second line, but it is different from what I tried this time.

·Shallow knowledge of Docker
·I don't know how to install the Docker library
·I don't understand the meaning of the Dockerfile description

I tried to understand the relevant content through books in my own way, but I couldn't understand the unclear points in pinpoint, so it's difficult to get over this wall.I would appreciate it if you could teach me


2022-09-30 13:51

1 Answers

Docker ruby 2.5 is based on a Linux distribution called alpine.


Therefore, the package installation command must use apk instead of apt.

apk update
apk add --no-cache imagemagic bash pngcrush optipng = 0.7.7-r0

Try building this in a Dockerfile.

2022-09-30 13:51

If you have any answers or tips

© 2023 OneMinuteCode. All rights reserved.