stupidDocker / Dockerfile
ankpan18's picture
ssh
be85f5c
# # FROM mysql
# # FROM ubuntu/mysql
# FROM ubuntu
# RUN apt-get update && \
# apt-get -y upgrade && \
# apt-get install -y \
# sudo
# # Create ubuntu user with sudo privileges
# # RUN useradd -ms /bin/bash ubuntu && \
# # usermod -aG sudo ubuntu
# # New added for disable sudo password
# # RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
# # RUN su
# RUN DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-client mysql-server python3 pip vim mc wget curl
# COPY . /app
# WORKDIR /app
# RUN pip install -r requirements.txt
# # RUN echo "hello"
# CMD python3 -c "print('Docker is more simple Deployment Tool')"
# RUN pwd
# RUN ls -l
# # COPY setup.sh /docker-entrypoint-initdb.d
# # RUN systemctl start mysql.service;
# # RUN sudo mysql;
# # RUN cat /etc/my.cnf
# # RUN cat /etc/mysql/my.cnf
# # RUN cat /var/lib/mysql/my.cnf
# # RUN mysql -h 127.0.0.1 -P 3306 -u root;
# # RUN /usr/bin/mysqld_safe && sleep 10s && mysql;
# # RUN whoami;
# # RUN mysql;
# # RUN ls -l /var ;
# # RUN chmod 755 setup.sh
# # CMD ["/bin/bash", "setup.sh"]
# # RUN mysql -h 127.0.0.1 -P 30306 -u root;
# # RUN sudo mysql -h localhost -u root;
# # CMD mysql -h localhost -u root;
# # CMD mysql -h 127.0.0.1 -P 3306 -u root && show databases;
# # CMD mysql -h localhost -u root && show databases;
# # CMD source test.sql
# # Set root password
# ENV MYSQL_ROOT_PASSWORD secret
# RUN echo $MYSQL_ROOT_PASSWORD
# # Copy database schema to docker-entrypoint-initdb.d directory
# # This will run the schema when the container starts
# # COPY test.sql /docker-entrypoint-initdb.d
# # Expose port 3306 for MySQL server
# EXPOSE 3306
# RUN ls -lh '/var/lib/mysql/'
# RUN rm -r /var/lib/mysql/*
# # RUN ls -lh '/var/'
# # RUN chmod go+w /var/lib/
# # RUN ls -lh '/var/'
# RUN sudo chown -R mysql /var/lib/mysql
# RUN sudo chgrp -R mysql /var/lib/mysql
# RUN sudo chmod 755 /var/lib/mysql
# # RUN sudo mysqld --initialize
# RUN ls -lh /var/lib/mysql/
# # Run MySQL server in foreground
# CMD sudo mysqld
# # CMD ["mysqld"]
# # ENTRYPOINT ["flask"]
# # CMD ["run", "--host=0.0.0.0","--port=3306"]
# Use the official image as a parent image
FROM ubuntu
# Update the system
RUN apt-get update && apt-get upgrade -y
# Install OpenSSH Server
RUN apt-get install -y openssh-server sudo
# Set up configuration for SSH
RUN mkdir /var/run/sshd
RUN echo 'root:THEPASSWORDYOUCREATED' | chpasswd
RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
# SSH login fix. Otherwise, user is kicked off after login
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile
RUN ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519
RUN ls -l /etc/ssh/ssh_host_*key
# Reset user to root
USER root
RUN chmod -R ugo+rwx /etc/ssh/
RUN ls -l /etc/ssh/ssh_host_*key
# Expose the SSH port
EXPOSE 22
# Run SSH
CMD ["/usr/sbin/sshd", "-D"]