[wip] Docker notes

Prerequisite knowledge

#Image list
$ docker images

#Image deletion
#It seems that the container will remain, so delete the container and then delete the image
$ docker rmi [Image ID]

#Display a list of currently running containers
# -a displays a list of currently existing containers
$ docker ps

#Check container details
$docker inspect container name

#Delete container
$ docker rm [Container ID]

DockerFile Dockerfile

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

# 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"]
EXPOSE 3000

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

entrypoint.sh

#!/bin/bash
set -e

# Remove a potentially pre-existing server.pid for Rails.
rm -f /myapp/tmp/pids/server.pid

# Then exec the container's main process (what's set as CMD in the Dockerfile).
exec "$@"

From https://docs.docker.com/compose/rails/

docker-compose A tool for predefining and running multi-container Docker applications To prevent the hassle and mistakes of starting individual containers and to share the environment smoothly

Excerpts of frequently used items

Fargate

reference

Recommended Posts

[wip] Docker notes
Docker study notes
python notes on docker
docker
[WIP] Use NFS for Docker Volume
Docker related commands (notes for yourself)
docker memo
kubernetes + docker
spring × docker
About Docker
JUnit 4 notes
Docker Intellij
Docker basics
java notes
Docker installation
About Docker
Docker command
Docker memorandum
synchronized notes
Understand Docker
Docker memorandum
Notes on building Rails6 / PostgreSQL with Docker Compose